Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-02-26 23:27:24
Exec Total Coverage
Lines: 1122 3870 29.0%
Functions: 94 341 27.6%
Branches: 515 2676 19.2%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 bool epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 static bool load_control_called_this_frame;
104 extern PALETTE* hw_palette;
105 extern bool update_hw_pal;
106 extern const char* dmaplist(int32_t index, int32_t* list_size);
107 int32_t getnumber(const char *prompt,int32_t initialval);
108
109 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
110 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
111 //extern byte refresh_select_screen;
112 //extern movingblock mblock2; //mblock[4]?
113 //extern int32_t db;
114
115 static const char *ZC_str = "Zelda Classic";
116 extern char save_file_name[1024];
117 #ifdef ALLEGRO_DOS
118 const char *qst_dir_name = "dos_qst_dir";
119 #elif defined(ALLEGRO_WINDOWS)
120 const char *qst_dir_name = "win_qst_dir";
121 static const char *qst_module_name = "current_module";
122 #elif defined(ALLEGRO_LINUX)
123 const char *qst_dir_name = "linux_qst_dir";
124 static const char *qst_module_name = "current_module";
125 #elif defined(__APPLE__)
126 const char *qst_dir_name = "osx_qst_dir";
127 static const char *qst_module_name = "current_module";
128 #endif
129 #ifdef ALLEGRO_LINUX
130 static const char *samplepath = "samplesoundset/patches.dat";
131 #endif
132 char qst_files_path[2048];
133
134 #ifdef _MSC_VER
135 #define getcwd _getcwd
136 #endif
137
138 bool rF11();
139 bool rI();
140 bool rQ();
141 bool zc_key_pressed();
142
143 #ifdef _WIN32
144
145 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
146 extern "C"
147 {
148 typedef HRESULT(WINAPI *t_DwmFlush)();
149 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
150 }
151
152 void do_DwmFlush()
153 {
154 static HMODULE shell = LoadLibrary("dwmapi.dll");
155
156 if(!shell)
157 return;
158
159 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
160 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
161
162 BOOL enabled;
163 isEnabled(&enabled);
164
165 if(isEnabled)
166 flush();
167 }
168
169 #endif // _WIN32
170
171 bool flash_reduction_enabled(bool check_qr)
172 {
173 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
174 }
175
176 // Dialogue largening
177 void large_dialog(DIALOG *d)
178 {
179 large_dialog(d, 1.5);
180 }
181
182 void large_dialog(DIALOG *d, float RESIZE_AMT)
183 {
184 if(!d[0].d1)
185 {
186 d[0].d1 = 1;
187 int32_t oldwidth = d[0].w;
188 int32_t oldheight = d[0].h;
189 int32_t oldx = d[0].x;
190 int32_t oldy = d[0].y;
191 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
192 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
193 d[0].w = int32_t(d[0].w*RESIZE_AMT);
194 d[0].h = int32_t(d[0].h*RESIZE_AMT);
195
196 for(int32_t i=1; d[i].proc !=NULL; i++)
197 {
198 // Place elements horizontally
199 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
200 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
201
202 if(d[i].proc != d_stringloader)
203 {
204 if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].w *= 2;
207 }
208 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
209 }
210
211 // Place elements vertically
212 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
213 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
214
215 // Vertically resize elements
216 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
217 {
218 d[i].h = int32_t((double)d[i].h*1.5);
219 }
220 else if(d[i].proc == jwin_droplist_proc)
221 {
222 d[i].y += int32_t((double)d[i].h*0.25);
223 d[i].h = int32_t((double)d[i].h*1.25);
224 }
225 else if(d[i].proc==d_bitmap_proc)
226 {
227 d[i].h *= 2;
228 }
229 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
230
231 // Fix frames
232 if(d[i].proc == jwin_frame_proc)
233 {
234 d[i].x++;
235 d[i].y++;
236 d[i].w-=4;
237 d[i].h-=4;
238 }
239 }
240 }
241
242 for(int32_t i=1; d[i].proc!=NULL; i++)
243 {
244 if(d[i].proc==jwin_slider_proc)
245 continue;
246
247 // Bigger font
248 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
249
250 if(!d[i].dp2 && bigfontproc)
251 {
252 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
253 d[i].dp2 = lfont_l;
254 }
255 else if(!bigfontproc)
256 {
257 // ((ListData *)d[i].dp)->font = &sfont3;
258 ((ListData *)d[i].dp)->font = &lfont_l;
259 }
260
261 // Make checkboxes work
262 if(d[i].proc == jwin_check_proc)
263 d[i].proc = jwin_checkfont_proc;
264 else if(d[i].proc == jwin_radio_proc)
265 d[i].proc = jwin_radiofont_proc;
266 }
267
268 jwin_center_dialog(d);
269 }
270
271
272 /**********************************/
273 /******** System functions ********/
274 /**********************************/
275
276 static char cfg_sect[] = "zeldadx"; //We need to rename this.
277 static char ctrl_sect[] = "Controls";
278 static char sfx_sect[] = "Volume";
279
280 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
281 {
282 return D_O_K;
283 }
284
285 bool checkcheat(Cheat cheat)
286 {
287 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
288 return true; //Main key pressed
289 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
290 return true; //Alt key pressed
291 return false;
292 }
293 29 void load_default_cheatkeys()
294 {
295 29 memset(cheatkeys, 0, sizeof(cheatkeys));
296 29 cheatkeys[Cheat::Life][0] = KEY_H;
297 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
298 29 cheatkeys[Cheat::Magic][0] = KEY_M;
299 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
300 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
301 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
302 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
303 29 cheatkeys[Cheat::Clock][0] = KEY_I;
304 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
305 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
306 29 cheatkeys[Cheat::Light][0] = KEY_L;
307 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
308 29 cheatkeys[Cheat::Kill][0] = KEY_K;
309 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
310 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
311 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
312 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
313 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
314 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
315 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
316 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
317 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
318 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
319 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
320 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
321 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
322 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
323 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
324 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
325 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
326 29 }
327 29 void load_game_configs()
328 {
329 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
330 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
331 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
332 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
333 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
334 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
335 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
336 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
337 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
338 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
339 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
340 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
341 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
342 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
343 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
344
345 //cheat modifier keya
346 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
347 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
348 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
349 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
350
351 //cheat keys
352 29 load_default_cheatkeys();
353 char buf[256];
354 29 al_trace("START CHEATS\n");
355
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
356 {
357
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
358 1015 std::string cheatname = cheat_to_string((Cheat)q);
359
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
360 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
361
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
362
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
366 1015 }
367 29 al_trace("END CHEATS\n");
368
369
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
370 joystick_index = 0;
371
372 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
373 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
374 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
375 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
376 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
377 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
378 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
379 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
380 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
381 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
382
383 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
384 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
385 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
386 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
387
388 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
389 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
390 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
391 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
392 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
393 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
394 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
395 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
396 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
397 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
398 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
399
400 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
401 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
402 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
403 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
404
405 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
406
407 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
408 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
409 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
410 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
411 29 pan_style = zc_get_config(sfx_sect,"pan",1);
412 // 1 <= zcmusic_bufsz <= 128
413 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
414 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
415 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
416 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
417 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
418 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
419 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
420 #ifdef __EMSCRIPTEN__
421 if (em_is_mobile()) NameEntryMode = 2;
422 #endif
423 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
424 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
425 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
426 29 title_version = zc_get_config(cfg_sect,"title",2);
427 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
428 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
429
430 //default - scale x2, 640 x 480
431 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
432 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
433 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
434 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
435 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
436
437 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 // And this one fixes patches unloading on some MIDI setups
455 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
456 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
457 #else //UNIX
458 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
461 #endif
462 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
463
464 29 char const* default_path = "";
465 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
468 {
469 29 getcwd(qstdir,2048);
470 29 fix_filename_case(qstdir);
471 29 fix_filename_slashes(qstdir);
472 29 put_backslash(qstdir);
473 29 }
474 else
475 {
476 chop_path(qstdir);
477 }
478
479 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
480 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
481 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
482 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
483 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
484 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
485 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
486 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
487 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
488 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
489 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
490 29 }
491
492 void save_control_configs(bool kb)
493 {
494 if(kb)
495 {
496 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
497 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
498 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
499 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
500
501 if (!replay_is_replaying())
502 {
503 zc_set_config(ctrl_sect,"key_a",Akey);
504 zc_set_config(ctrl_sect,"key_b",Bkey);
505 zc_set_config(ctrl_sect,"key_s",Skey);
506 zc_set_config(ctrl_sect,"key_l",Lkey);
507 zc_set_config(ctrl_sect,"key_r",Rkey);
508 zc_set_config(ctrl_sect,"key_p",Pkey);
509 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
510 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
511 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
512 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
513 zc_set_config(ctrl_sect,"key_up", DUkey);
514 zc_set_config(ctrl_sect,"key_down", DDkey);
515 zc_set_config(ctrl_sect,"key_left", DLkey);
516 zc_set_config(ctrl_sect,"key_right",DRkey);
517 }
518 }
519 else
520 {
521 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
522 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
523 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
524 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
525 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
526 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
527 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
528 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
529 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
530 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
531 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
532 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
533 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
534 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
535
536 zc_set_config(ctrl_sect,"btn_a",Abtn);
537 zc_set_config(ctrl_sect,"btn_b",Bbtn);
538 zc_set_config(ctrl_sect,"btn_s",Sbtn);
539 zc_set_config(ctrl_sect,"btn_m",Mbtn);
540 zc_set_config(ctrl_sect,"btn_l",Lbtn);
541 zc_set_config(ctrl_sect,"btn_r",Rbtn);
542 zc_set_config(ctrl_sect,"btn_p",Pbtn);
543 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
544 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
545 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
546 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
547
548 zc_set_config(ctrl_sect,"btn_up",DUbtn);
549 zc_set_config(ctrl_sect,"btn_down",DDbtn);
550 zc_set_config(ctrl_sect,"btn_left",DLbtn);
551 zc_set_config(ctrl_sect,"btn_right",DRbtn);
552 }
553 }
554
555 void save_cheatkeys()
556 {
557 char buf[256];
558 for(size_t q = 1; q < Cheat::Last; ++q)
559 {
560 if(!bindable_cheat((Cheat)q)) continue;
561 std::string cheatname = cheat_to_string((Cheat)q);
562 util::lowerstr(cheatname);
563 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
564 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
565 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
566 if(cheatkeys[q][1])
567 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
568 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
569 }
570 }
571
572 void save_game_configs()
573 {
574 packfile_password("");
575
576 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
577
578 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
579 {
580 int o_window_x, o_window_y;
581 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
582 zc_set_config(cfg_sect,"window_x",o_window_x);
583 zc_set_config(cfg_sect,"window_y",o_window_y);
584 }
585
586 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
587 {
588 double monitor_scale = zc_get_monitor_scale();
589 window_width = al_get_display_width(all_get_display()) / monitor_scale;
590 window_height = al_get_display_height(all_get_display()) / monitor_scale;
591 zc_set_config(cfg_sect,"window_width",window_width);
592 zc_set_config(cfg_sect,"window_height",window_height);
593 }
594
595 zc_set_config(cfg_sect,"load_last",loadlast);
596 chop_path(qstdir);
597 zc_set_config(cfg_sect,qst_dir_name,qstdir);
598 zc_set_config("SAVEFILE","save_filename",save_file_name);
599 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
600
601 flush_config_file();
602 #ifdef __EMSCRIPTEN__
603 em_sync_fs();
604 #endif
605 }
606
607 //----------------------------------------------------------------
608
609 // Timers
610
611 238 void fps_callback()
612 {
613 238 lastfps=framecnt;
614 238 dword tempsecs = fps_secs;
615 238 ++tempsecs;
616 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
617 238 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
618 238 ++fps_secs;
619 238 framecnt=0;
620 238 }
621
622 END_OF_FUNCTION(fps_callback)
623
624 29 int32_t Z_init_timers()
625 {
626 static bool didit = false;
627 const static char *err_str = "Couldn't allocate timer";
628 29 err_str = err_str; //Unused variable warning
629
630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
631 return 1;
632
633 29 didit = true;
634
635 LOCK_VARIABLE(lastfps);
636 LOCK_VARIABLE(framecnt);
637 LOCK_FUNCTION(fps_callback);
638
639
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
640 return 0;
641
642 29 return 1;
643 29 }
644
645 void Z_remove_timers()
646 {
647 remove_int(fps_callback);
648 }
649
650 //----------------------------------------------------------------
651
652 void go()
653 {
654 scare_mouse();
655 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
656 unscare_mouse();
657 }
658
659 void comeback()
660 {
661 scare_mouse();
662 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
663 unscare_mouse();
664 }
665
666 void dump_pal(BITMAP *dest)
667 {
668 for(int32_t i=0; i<256; i++)
669 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
670 }
671
672 //----------------------------------------------------------------
673
674 //Handles converting the mouse sprite from the .dat file
675 29 void load_mouse()
676 {
677 29 system_pal();
678 29 scare_mouse();
679 29 set_mouse_sprite(NULL);
680 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
681
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
682 {
683 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
684 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
685
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
686 destroy_bitmap(zcmouse[j]);
687 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
688 116 clear_bitmap(zcmouse[j]);
689 116 clear_bitmap(tmpbmp);
690 116 clear_bitmap(subbmp);
691 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
692
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
693 {
694
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
695 {
696 29696 int32_t color = getpixel(tmpbmp, x, y);
697
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
698 {
699 case dvc(1):
700 551 color = jwin_pal[jcCURSORMISC];
701 551 break;
702 case dvc(2):
703 638 color = jwin_pal[jcCURSOROUTLINE];
704 638 break;
705 case dvc(3):
706 667 color = jwin_pal[jcCURSORLIGHT];
707 667 break;
708 case dvc(5):
709 522 color = jwin_pal[jcCURSORDARK];
710 522 break;
711 }
712 29696 putpixel(subbmp, x, y, color);
713 29696 }
714 1856 }
715
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
716 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
717 else
718 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
719 116 destroy_bitmap(tmpbmp);
720 116 destroy_bitmap(subbmp);
721 116 }
722 29 set_mouse_sprite(zcmouse[0]);
723
724 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
725 29 set_palette(*hw_palette);
726 29 show_mouse(screen);
727 29 show_mouse(NULL);
728
729 29 unscare_mouse();
730 29 game_pal();
731 29 }
732
733 // sets the video mode and initializes the palette and mouse sprite
734 29 bool game_vid_mode(int32_t mode,int32_t wait)
735 {
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
737 {
738 return false;
739 }
740
741 29 scrx = (resx-320)>>1;
742 29 scry = (resy-240)>>1;
743
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
744 116 zcmouse[q] = NULL;
745 29 load_mouse();
746 29 set_mouse_sprite(zcmouse[0]);
747
748
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
749 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
750
751 29 set_palette(RAMpal);
752 29 clear_to_color(screen,BLACK);
753
754 29 rest(wait);
755 29 return true;
756 29 }
757
758 void null_quest()
759 {
760 char qstdat_string[2048];
761 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
762 strcat(qstdat_string,"#NESQST_NEW_QST");
763
764 #ifdef __EMSCRIPTEN__
765 // The quest template data file is not included because it's really big and isn't really needed
766 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
767 // which is much smaller.
768 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
769 #endif
770
771 byte skip_flags[4] = { 0 };
772
773 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
774 }
775
776 void init_NES_mode()
777 {
778 /*
779 // qst.dat may not load correctly without this...
780 QHeader.templatepath[0]='\0';
781
782 if(!init_colordata(true, &QHeader, &QMisc))
783 {
784 return;
785 }
786
787 loadfullpal();
788 init_tiles(false, &QHeader);
789 */
790 null_quest();
791 }
792
793 //----------------------------------------------------------------
794
795 qword trianglelines[16]=
796 {
797 0x0000000000000000ULL,
798 0xFD00000000000000ULL,
799 0xFDFD000000000000ULL,
800 0xFDFDFD0000000000ULL,
801 0xFDFDFDFD00000000ULL,
802 0xFDFDFDFDFD000000ULL,
803 0xFDFDFDFDFDFD0000ULL,
804 0xFDFDFDFDFDFDFD00ULL,
805 0xFDFDFDFDFDFDFDFDULL,
806 0x00FDFDFDFDFDFDFDULL,
807 0x0000FDFDFDFDFDFDULL,
808 0x000000FDFDFDFDFDULL,
809 0x00000000FDFDFDFDULL,
810 0x0000000000FDFDFDULL,
811 0x000000000000FDFDULL,
812 0x00000000000000FDULL,
813 };
814
815 word screen_triangles[28][32];
816 /*
817 qword triangles[4][16]= //[direction][value]
818 {
819 {
820 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
821 },
822 {
823 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
824 },
825 {
826 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
827 },
828 {
829 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
830 }
831 };
832 */
833
834
835 /*
836 byte triangles[4][16][8]= //[direction][value][line]
837 {
838 {
839 {
840 0, 0, 0, 0, 0, 0, 0, 0
841 },
842 {
843 1, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 2, 1, 0, 0, 0, 0, 0, 0
847 },
848 {
849 3, 2, 1, 0, 0, 0, 0, 0
850 },
851 {
852 4, 3, 2, 1, 0, 0, 0, 0
853 },
854 {
855 5, 4, 3, 2, 1, 0, 0, 0
856 },
857 {
858 6, 5, 4, 3, 2, 1, 0, 0
859 },
860 {
861 7, 6, 5, 4, 3, 2, 1, 0
862 },
863 {
864 8, 7, 6, 5, 4, 3, 2, 1
865 },
866 {
867 8, 8, 7, 6, 5, 4, 3, 2
868 },
869 {
870 8, 8, 8, 7, 6, 5, 4, 3
871 },
872 {
873 8, 8, 8, 8, 7, 6, 5, 4
874 },
875 {
876 8, 8, 8, 8, 8, 7, 6, 5
877 },
878 {
879 8, 8, 8, 8, 8, 8, 7, 6
880 },
881 {
882 8, 8, 8, 8, 8, 8, 8, 7
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 8
886 }
887 },
888 {
889 {
890 0, 0, 0, 0, 0, 0, 0, 0
891 },
892 {
893 15, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 14, 15, 0, 0, 0, 0, 0, 0
897 },
898 {
899 13, 14, 15, 0, 0, 0, 0, 0
900 },
901 {
902 12, 13, 14, 15, 0, 0, 0, 0
903 },
904 {
905 11, 12, 13, 14, 15, 0, 0, 0
906 },
907 {
908 10, 11, 12, 13, 14, 15, 0, 0
909 },
910 {
911 9, 10, 11, 12, 13, 14, 15, 0
912 },
913 {
914 8, 9, 10, 11, 12, 13, 14, 15
915 },
916 {
917 8, 8, 9, 10, 11, 12, 13, 14
918 },
919 {
920 8, 8, 8, 9, 10, 11, 12, 13
921 },
922 {
923 8, 8, 8, 8, 9, 10, 11, 12
924 },
925 {
926 8, 8, 8, 8, 8, 9, 10, 11
927 },
928 {
929 8, 8, 8, 8, 8, 8, 9, 10
930 },
931 {
932 8, 8, 8, 8, 8, 8, 8, 9
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 8
936 }
937 },
938 {
939 {
940 0, 0, 0, 0, 0, 0, 0, 0
941 },
942 {
943 0, 0, 0, 0, 0, 0, 0, 1
944 },
945 {
946 0, 0, 0, 0, 0, 0, 1, 2
947 },
948 {
949 0, 0, 0, 0, 0, 1, 2, 3
950 },
951 {
952 0, 0, 0, 0, 1, 2, 3, 4
953 },
954 {
955 0, 0, 0, 1, 2, 3, 4, 5
956 },
957 {
958 0, 0, 1, 2, 3, 4, 5, 6
959 },
960 {
961 0, 1, 2, 3, 4, 5, 6, 7
962 },
963 {
964 1, 2, 3, 4, 5, 6, 7, 8
965 },
966 {
967 2, 3, 4, 5, 6, 7, 8, 8
968 },
969 {
970 3, 4, 5, 6, 7, 8, 8, 8
971 },
972 {
973 4, 5, 6, 7, 8, 8, 8, 8
974 },
975 {
976 5, 6, 7, 8, 8, 8, 8, 8
977 },
978 {
979 6, 7, 8, 8, 8, 8, 8, 8
980 },
981 {
982 7, 8, 8, 8, 8, 8, 8, 8
983 },
984 {
985 8, 8, 8, 8, 8, 8, 8, 8
986 }
987 },
988 {
989 {
990 0, 0, 0, 0, 0, 0, 0, 0
991 },
992 {
993 0, 0, 0, 0, 0, 0, 0, 15
994 },
995 {
996 0, 0, 0, 0, 0, 0, 15, 14
997 },
998 {
999 0, 0, 0, 0, 0, 15, 14, 13
1000 },
1001 {
1002 0, 0, 0, 0, 15, 14, 13, 12
1003 },
1004 {
1005 0, 0, 0, 15, 14, 13, 12, 11
1006 },
1007 {
1008 0, 0, 15, 14, 13, 12, 11, 10
1009 },
1010 {
1011 0, 15, 14, 13, 12, 11, 10, 9
1012 },
1013 {
1014 15, 14, 13, 12, 11, 10, 9, 8
1015 },
1016 {
1017 14, 13, 12, 11, 10, 9, 8, 8
1018 },
1019 {
1020 13, 12, 11, 10, 9, 8, 8, 8
1021 },
1022 {
1023 12, 11, 10, 9, 8, 8, 8, 8
1024 },
1025 {
1026 11, 10, 9, 8, 8, 8, 8, 8
1027 },
1028 {
1029 10, 9, 8, 8, 8, 8, 8, 8
1030 },
1031 {
1032 9, 8, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 8, 8, 8, 8, 8, 8, 8, 8
1036 }
1037 }
1038 };
1039 */
1040
1041
1042
1043 /*
1044 for (int32_t blockrow=0; blockrow<30; ++i)
1045 {
1046 for (int32_t linerow=0; linerow<8; ++i)
1047 {
1048 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1049 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1050 {
1051 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1052 ++triangleline;
1053 }
1054 }
1055 }
1056 */
1057
1058 // the ULL suffixes are to prevent this warning:
1059 // warning: integer constant is too large for "int32_t" type
1060
1061 qword triangles[4][16][8]= //[direction][value][line]
1062 {
1063 {
1064 {
1065 0x0000000000000000ULL,
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL
1073 },
1074 {
1075 0xFD00000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL
1083 },
1084 {
1085 0xFDFD000000000000ULL,
1086 0xFD00000000000000ULL,
1087 0x0000000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL
1093 },
1094 {
1095 0xFDFDFD0000000000ULL,
1096 0xFDFD000000000000ULL,
1097 0xFD00000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL
1103 },
1104 {
1105 0xFDFDFDFD00000000ULL,
1106 0xFDFDFD0000000000ULL,
1107 0xFDFD000000000000ULL,
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL
1113 },
1114 {
1115 0xFDFDFDFDFD000000ULL,
1116 0xFDFDFDFD00000000ULL,
1117 0xFDFDFD0000000000ULL,
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL
1123 },
1124 {
1125 0xFDFDFDFDFDFD0000ULL,
1126 0xFDFDFDFDFD000000ULL,
1127 0xFDFDFDFD00000000ULL,
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL
1133 },
1134 {
1135 0xFDFDFDFDFDFDFD00ULL,
1136 0xFDFDFDFDFDFD0000ULL,
1137 0xFDFDFDFDFD000000ULL,
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL,
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL
1143 },
1144 {
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFD00ULL,
1147 0xFDFDFDFDFDFD0000ULL,
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL,
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL
1153 },
1154 {
1155 0xFDFDFDFDFDFDFDFDULL,
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFD00ULL,
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL,
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL
1163 },
1164 {
1165 0xFDFDFDFDFDFDFDFDULL,
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL,
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL
1173 },
1174 {
1175 0xFDFDFDFDFDFDFDFDULL,
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL,
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL
1183 },
1184 {
1185 0xFDFDFDFDFDFDFDFDULL,
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL,
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL
1193 },
1194 {
1195 0xFDFDFDFDFDFDFDFDULL,
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL
1203 },
1204 {
1205 0xFDFDFDFDFDFDFDFDULL,
1206 0xFDFDFDFDFDFDFDFDULL,
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL
1213 },
1214 {
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL
1223 }
1224 },
1225 {
1226 {
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL
1235 },
1236 {
1237 0x00000000000000FDULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL
1245 },
1246 {
1247 0x000000000000FDFDULL,
1248 0x00000000000000FDULL,
1249 0x0000000000000000ULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL
1255 },
1256 {
1257 0x0000000000FDFDFDULL,
1258 0x000000000000FDFDULL,
1259 0x00000000000000FDULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL
1265 },
1266 {
1267 0x00000000FDFDFDFDULL,
1268 0x0000000000FDFDFDULL,
1269 0x000000000000FDFDULL,
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL
1275 },
1276 {
1277 0x000000FDFDFDFDFDULL,
1278 0x00000000FDFDFDFDULL,
1279 0x0000000000FDFDFDULL,
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL
1285 },
1286 {
1287 0x0000FDFDFDFDFDFDULL,
1288 0x000000FDFDFDFDFDULL,
1289 0x00000000FDFDFDFDULL,
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL
1295 },
1296 {
1297 0x00FDFDFDFDFDFDFDULL,
1298 0x0000FDFDFDFDFDFDULL,
1299 0x000000FDFDFDFDFDULL,
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL,
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL
1305 },
1306 {
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0x00FDFDFDFDFDFDFDULL,
1309 0x0000FDFDFDFDFDFDULL,
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL,
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL
1315 },
1316 {
1317 0xFDFDFDFDFDFDFDFDULL,
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0x00FDFDFDFDFDFDFDULL,
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL,
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL
1325 },
1326 {
1327 0xFDFDFDFDFDFDFDFDULL,
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL,
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL
1335 },
1336 {
1337 0xFDFDFDFDFDFDFDFDULL,
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL,
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL
1345 },
1346 {
1347 0xFDFDFDFDFDFDFDFDULL,
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL,
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL
1355 },
1356 {
1357 0xFDFDFDFDFDFDFDFDULL,
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL
1365 },
1366 {
1367 0xFDFDFDFDFDFDFDFDULL,
1368 0xFDFDFDFDFDFDFDFDULL,
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL
1375 },
1376 {
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL
1385 }
1386 },
1387 {
1388 {
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL
1397 },
1398 {
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0xFD00000000000000ULL
1407 },
1408 {
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0xFD00000000000000ULL,
1416 0xFDFD000000000000ULL
1417 },
1418 {
1419 0x0000000000000000ULL,
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0xFD00000000000000ULL,
1425 0xFDFD000000000000ULL,
1426 0xFDFDFD0000000000ULL
1427 },
1428 {
1429 0x0000000000000000ULL,
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0xFD00000000000000ULL,
1434 0xFDFD000000000000ULL,
1435 0xFDFDFD0000000000ULL,
1436 0xFDFDFDFD00000000ULL
1437 },
1438 {
1439 0x0000000000000000ULL,
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL,
1442 0xFD00000000000000ULL,
1443 0xFDFD000000000000ULL,
1444 0xFDFDFD0000000000ULL,
1445 0xFDFDFDFD00000000ULL,
1446 0xFDFDFDFDFD000000ULL
1447 },
1448 {
1449 0x0000000000000000ULL,
1450 0x0000000000000000ULL,
1451 0xFD00000000000000ULL,
1452 0xFDFD000000000000ULL,
1453 0xFDFDFD0000000000ULL,
1454 0xFDFDFDFD00000000ULL,
1455 0xFDFDFDFDFD000000ULL,
1456 0xFDFDFDFDFDFD0000ULL
1457 },
1458 {
1459 0x0000000000000000ULL,
1460 0xFD00000000000000ULL,
1461 0xFDFD000000000000ULL,
1462 0xFDFDFD0000000000ULL,
1463 0xFDFDFDFD00000000ULL,
1464 0xFDFDFDFDFD000000ULL,
1465 0xFDFDFDFDFDFD0000ULL,
1466 0xFDFDFDFDFDFDFD00ULL
1467 },
1468 {
1469 0xFD00000000000000ULL,
1470 0xFDFD000000000000ULL,
1471 0xFDFDFD0000000000ULL,
1472 0xFDFDFDFD00000000ULL,
1473 0xFDFDFDFDFD000000ULL,
1474 0xFDFDFDFDFDFD0000ULL,
1475 0xFDFDFDFDFDFDFD00ULL,
1476 0xFDFDFDFDFDFDFDFDULL
1477 },
1478 {
1479 0xFDFD000000000000ULL,
1480 0xFDFDFD0000000000ULL,
1481 0xFDFDFDFD00000000ULL,
1482 0xFDFDFDFDFD000000ULL,
1483 0xFDFDFDFDFDFD0000ULL,
1484 0xFDFDFDFDFDFDFD00ULL,
1485 0xFDFDFDFDFDFDFDFDULL,
1486 0xFDFDFDFDFDFDFDFDULL
1487 },
1488 {
1489 0xFDFDFD0000000000ULL,
1490 0xFDFDFDFD00000000ULL,
1491 0xFDFDFDFDFD000000ULL,
1492 0xFDFDFDFDFDFD0000ULL,
1493 0xFDFDFDFDFDFDFD00ULL,
1494 0xFDFDFDFDFDFDFDFDULL,
1495 0xFDFDFDFDFDFDFDFDULL,
1496 0xFDFDFDFDFDFDFDFDULL
1497 },
1498 {
1499 0xFDFDFDFD00000000ULL,
1500 0xFDFDFDFDFD000000ULL,
1501 0xFDFDFDFDFDFD0000ULL,
1502 0xFDFDFDFDFDFDFD00ULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL
1507 },
1508 {
1509 0xFDFDFDFDFD000000ULL,
1510 0xFDFDFDFDFDFD0000ULL,
1511 0xFDFDFDFDFDFDFD00ULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL
1517 },
1518 {
1519 0xFDFDFDFDFDFD0000ULL,
1520 0xFDFDFDFDFDFDFD00ULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL
1527 },
1528 {
1529 0xFDFDFDFDFDFDFD00ULL,
1530 0xFDFDFDFDFDFDFDFDULL,
1531 0xFDFDFDFDFDFDFDFDULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL
1537 },
1538 {
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL
1547 }
1548 },
1549 {
1550 {
1551 0x0000000000000000ULL,
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL
1559 },
1560 {
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x00000000000000FDULL
1569 },
1570 {
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x00000000000000FDULL,
1578 0x000000000000FDFDULL
1579 },
1580 {
1581 0x0000000000000000ULL,
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x00000000000000FDULL,
1587 0x000000000000FDFDULL,
1588 0x0000000000FDFDFDULL
1589 },
1590 {
1591 0x0000000000000000ULL,
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x00000000000000FDULL,
1596 0x000000000000FDFDULL,
1597 0x0000000000FDFDFDULL,
1598 0x00000000FDFDFDFDULL
1599 },
1600 {
1601 0x0000000000000000ULL,
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL,
1604 0x00000000000000FDULL,
1605 0x000000000000FDFDULL,
1606 0x0000000000FDFDFDULL,
1607 0x00000000FDFDFDFDULL,
1608 0x000000FDFDFDFDFDULL
1609 },
1610 {
1611 0x0000000000000000ULL,
1612 0x0000000000000000ULL,
1613 0x00000000000000FDULL,
1614 0x000000000000FDFDULL,
1615 0x0000000000FDFDFDULL,
1616 0x00000000FDFDFDFDULL,
1617 0x000000FDFDFDFDFDULL,
1618 0x0000FDFDFDFDFDFDULL
1619 },
1620 {
1621 0x0000000000000000ULL,
1622 0x00000000000000FDULL,
1623 0x000000000000FDFDULL,
1624 0x0000000000FDFDFDULL,
1625 0x00000000FDFDFDFDULL,
1626 0x000000FDFDFDFDFDULL,
1627 0x0000FDFDFDFDFDFDULL,
1628 0x00FDFDFDFDFDFDFDULL
1629 },
1630 {
1631 0x00000000000000FDULL,
1632 0x000000000000FDFDULL,
1633 0x0000000000FDFDFDULL,
1634 0x00000000FDFDFDFDULL,
1635 0x000000FDFDFDFDFDULL,
1636 0x0000FDFDFDFDFDFDULL,
1637 0x00FDFDFDFDFDFDFDULL,
1638 0xFDFDFDFDFDFDFDFDULL
1639 },
1640 {
1641 0x000000000000FDFDULL,
1642 0x0000000000FDFDFDULL,
1643 0x00000000FDFDFDFDULL,
1644 0x000000FDFDFDFDFDULL,
1645 0x0000FDFDFDFDFDFDULL,
1646 0x00FDFDFDFDFDFDFDULL,
1647 0xFDFDFDFDFDFDFDFDULL,
1648 0xFDFDFDFDFDFDFDFDULL
1649 },
1650 {
1651 0x0000000000FDFDFDULL,
1652 0x00000000FDFDFDFDULL,
1653 0x000000FDFDFDFDFDULL,
1654 0x0000FDFDFDFDFDFDULL,
1655 0x00FDFDFDFDFDFDFDULL,
1656 0xFDFDFDFDFDFDFDFDULL,
1657 0xFDFDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL
1659 },
1660 {
1661 0x00000000FDFDFDFDULL,
1662 0x000000FDFDFDFDFDULL,
1663 0x0000FDFDFDFDFDFDULL,
1664 0x00FDFDFDFDFDFDFDULL,
1665 0xFDFDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL
1669 },
1670 {
1671 0x000000FDFDFDFDFDULL,
1672 0x0000FDFDFDFDFDFDULL,
1673 0x00FDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL
1679 },
1680 {
1681 0x0000FDFDFDFDFDFDULL,
1682 0x00FDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL
1689 },
1690 {
1691 0x00FDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL
1699 },
1700 {
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL
1709 }
1710 }
1711 };
1712
1713 int32_t black_opening_count=0;
1714 int32_t black_opening_x,black_opening_y;
1715 int32_t black_opening_shape;
1716
1717 23 int32_t choose_opening_shape()
1718 {
1719 // First, count how many bits are set
1720 23 int32_t numBits=0;
1721 int32_t bitCounter;
1722
1723
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 23 times.
138 for(int32_t i=0; i<bosMAX; i++)
1724 {
1725
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 26 times.
115 if(COOLSCROLL&(1<<i))
1726 26 numBits++;
1727 115 }
1728
1729 // Shouldn't happen...
1730
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(numBits==0)
1731 return bosCIRCLE;
1732
1733 // Pick a bit
1734 23 bitCounter=zc_rand()%numBits+1;
1735
1736
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t i=0; i<bosMAX; i++)
1737 {
1738 // If this bit is set, decrement the bit counter
1739
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 26 times.
32 if(COOLSCROLL&(1<<i))
1740 26 bitCounter--;
1741
1742 // When the counter hits 0, return a value based on
1743 // which bit it stopped on.
1744 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1745
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 10 times.
32 if(bitCounter==0)
1746 22 return i;
1747 10 }
1748
1749 // Shouldn't be necessary, but the compiler might complain, at least
1750 1 return bosCIRCLE;
1751 23 }
1752
1753 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1754 {
1755 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1756
1757 int32_t w=256, h=224;
1758 int32_t blockrows=28, blockcolumns=32;
1759 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1760
1761 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1762 {
1763 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1764 {
1765 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1766 }
1767 }
1768
1769 black_opening_count = 66;
1770 black_opening_x = x;
1771 black_opening_y = y;
1772 lensclk = 0;
1773 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1774
1775
1776 if(black_opening_shape == bosFADEBLACK)
1777 {
1778 refreshTints();
1779 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1780 }
1781 if(wait)
1782 {
1783 FFCore.warpScriptCheck();
1784 for(int32_t i=0; i<66; i++)
1785 {
1786 draw_screen(tmpscr);
1787 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1788 advanceframe(true);
1789
1790 if(Quit)
1791 {
1792 break;
1793 }
1794 }
1795 }
1796 }
1797
1798 23 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1799 {
1800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1801
1802 23 int32_t w=256, h=224;
1803 23 int32_t blockrows=28, blockcolumns=32;
1804 23 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1805
1806
2/2
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 23 times.
667 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1807 {
1808
2/2
✓ Branch 0 taken 20608 times.
✓ Branch 1 taken 644 times.
21252 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1809 {
1810
2/2
✓ Branch 0 taken 10357 times.
✓ Branch 1 taken 10251 times.
20608 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1811 20608 }
1812 644 }
1813
1814 23 black_opening_count = -66;
1815 23 black_opening_x = x;
1816 23 black_opening_y = y;
1817 23 lensclk = 0;
1818
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(black_opening_shape == bosFADEBLACK)
1819 {
1820 refreshTints();
1821 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1822 }
1823
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if(wait)
1824 {
1825 22 FFCore.warpScriptCheck();
1826
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1506 times.
1528 for(int32_t i=0; i<66; i++)
1827 {
1828 1506 draw_screen(tmpscr);
1829 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1830 1506 advanceframe(true);
1831
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1506 times.
1506 if(Quit)
1833 {
1834 break;
1835 }
1836 1506 }
1837 22 }
1838 23 }
1839
1840 1507 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1841 {
1842 1507 clear_to_color(tmp_scr,BLACK);
1843 1507 int32_t w=256, h=224;
1844
1845
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1375 times.
1507 switch(black_opening_shape)
1846 {
1847 case bosOVAL:
1848 {
1849 double new_w=(w/2)+abs(w/2-x);
1850 double new_h=(h/2)+abs(h/2-y);
1851 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1852 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1853 break;
1854 }
1855
1856 case bosTRIANGLE:
1857 {
1858 66 double new_w=(w/2)+abs(w/2-x);
1859 66 double new_h=(h/2)+abs(h/2-y);
1860 66 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1861 66 double P2= (PI/2);
1862 66 double P23=(2*PI/3);
1863 66 double P43=(4*PI/3);
1864 66 double Pa= (-4*PI*a/(3*max_a));
1865 66 double angle=P2+Pa;
1866 66 double a0=angle;
1867 66 double a2=angle+P23;
1868 66 double a4=angle+P43;
1869 132 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1870 66 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1871 66 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1872 0);
1873 66 break;
1874 }
1875
1876 case bosSMAS:
1877 {
1878
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1879
1880
2/2
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 66 times.
1914 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1881 {
1882
2/2
✓ Branch 0 taken 14784 times.
✓ Branch 1 taken 1848 times.
16632 for(int32_t linerow=0; linerow<8; ++linerow)
1883 {
1884 14784 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1885
1886
2/2
✓ Branch 0 taken 473088 times.
✓ Branch 1 taken 14784 times.
487872 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1887 {
1888 1419264 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1889
6/6
✓ Branch 0 taken 332640 times.
✓ Branch 1 taken 140448 times.
✓ Branch 2 taken 314688 times.
✓ Branch 3 taken 158400 times.
✓ Branch 4 taken 174240 times.
✓ Branch 5 taken 140448 times.
473088 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1890 473088 [linerow];
1891 473088 ++triangleline;
1892
1893
2/2
✓ Branch 0 taken 413952 times.
✓ Branch 1 taken 59136 times.
473088 if(linerow==0)
1894 {
1895 59136 }
1896 473088 }
1897 14784 }
1898 1848 }
1899
1900 66 break;
1901 }
1902
1903 case bosFADEBLACK:
1904 {
1905 if(black_opening_count<0)
1906 {
1907 black_fade(zc_min(-black_opening_count,63));
1908 }
1909 else if(black_opening_count>0)
1910 {
1911 black_fade(63-zc_max(black_opening_count-3,0));
1912 }
1913 else black_fade(0);
1914 return; //no blitting from tmp_scr!
1915 }
1916
1917 1375 case bosCIRCLE:
1918 default:
1919 {
1920 1375 double new_w=(w/2)+abs(w/2-x);
1921 1375 double new_h=(h/2)+abs(h/2-y);
1922 1375 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1923 //circlefill(tmp_scr,x,y,a<<3,0);
1924 1375 circlefill(tmp_scr,x,y,r,0);
1925 1375 break;
1926 }
1927 }
1928
1929 1507 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1930 1507 }
1931
1932
1933 void black_fade(int32_t fadeamnt)
1934 {
1935 for(int32_t i=0; i < 0xEF; i++)
1936 {
1937 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1938 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1939 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1940 }
1941
1942 refreshpal = true;
1943 }
1944
1945 //----------------------------------------------------------------
1946
1947 18335 bool item_disabled(int32_t item) //is this item disabled?
1948 {
1949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18335 times.
18335 return (item>=0 && game->items_off[item] != 0);
1950 }
1951
1952 1454 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1953 {
1954
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 1351 times.
1454 if(current_item(item_type, true) >=item)
1955 {
1956 103 return true;
1957 }
1958
1959 1351 return false;
1960 1454 }
1961
1962 7261 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1963 {
1964
4/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1762 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3687 times.
✓ Branch 7 taken 963 times.
✓ Branch 8 taken 849 times.
7261 switch(item_type)
1965 {
1966 case itype_bomb:
1967 case itype_sbomb:
1968 {
1969 int32_t itemid = getItemID(itemsbuf, item_type, it);
1970
1971 if(itemid == -1)
1972 return false;
1973
1974 return (game->get_item(itemid));
1975 }
1976
1977 case itype_clock:
1978 {
1979 1762 int32_t itemid = getItemID(itemsbuf, item_type, it);
1980
1981
2/4
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1762 times.
✗ Branch 3 not taken.
1762 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1982 return (game->get_item(itemid));
1983 1762 return Hero.getClock()?1:0;
1984 }
1985
1986 case itype_key:
1987 return (game->get_keys()>0);
1988
1989 case itype_magiccontainer:
1990 return (game->get_maxmagic()>=game->get_mp_per_block());
1991
1992 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1993 {
1994 switch(it)
1995 {
1996 case -2:
1997 {
1998 for(int32_t i=0; i<MAXLEVELS; i++)
1999 {
2000 if(game->lvlitems[i]&liTRIFORCE)
2001 {
2002 return true;
2003 }
2004 }
2005
2006 return false;
2007 }
2008
2009 case -1:
2010 return (game->lvlitems[dlevel]&liTRIFORCE);
2011
2012 default:
2013 if(it>=0&&it<MAXLEVELS)
2014 {
2015 return (game->lvlitems[it]&liTRIFORCE);
2016 }
2017
2018 break;
2019 }
2020
2021 return 0;
2022 }
2023
2024 case itype_map: //it: -2=any, -1=current level, other=that level
2025 {
2026
1/3
✓ Branch 0 taken 3687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3687 switch(it)
2027 {
2028 case -2:
2029 {
2030 for(int32_t i=0; i<MAXLEVELS; i++)
2031 {
2032 if(game->lvlitems[i]&liMAP)
2033 {
2034 return true;
2035 }
2036 }
2037
2038 return false;
2039 }
2040
2041 case -1:
2042 return (game->lvlitems[dlevel]&liMAP)!=0;
2043
2044 default:
2045
2/4
✓ Branch 0 taken 3687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3687 times.
3687 if(it>=0&&it<MAXLEVELS)
2046 {
2047 3687 return (game->lvlitems[it]&liMAP)!=0;
2048 }
2049
2050 break;
2051 }
2052
2053 return 0;
2054 }
2055
2056 case itype_compass: //it: -2=any, -1=current level, other=that level
2057 {
2058
1/3
✓ Branch 0 taken 963 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
963 switch(it)
2059 {
2060 case -2:
2061 {
2062 for(int32_t i=0; i<MAXLEVELS; i++)
2063 {
2064 if(game->lvlitems[i]&liCOMPASS)
2065 {
2066 return true;
2067 }
2068 }
2069
2070 return false;
2071 }
2072
2073 case -1:
2074 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2075
2076 default:
2077
2/4
✓ Branch 0 taken 963 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 963 times.
✗ Branch 3 not taken.
963 if(it>=0&&it<MAXLEVELS)
2078 {
2079 963 return (game->lvlitems[it]&liCOMPASS)!=0;
2080 }
2081
2082 break;
2083 }
2084 return 0;
2085 }
2086
2087 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2088 {
2089
1/3
✓ Branch 0 taken 849 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
849 switch(it)
2090 {
2091 case -2:
2092 {
2093 for(int32_t i=0; i<MAXLEVELS; i++)
2094 {
2095 if(game->lvlitems[i]&liBOSSKEY)
2096 {
2097 return true;
2098 }
2099 }
2100
2101 return false;
2102 }
2103
2104 case -1:
2105 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2106
2107 default:
2108
2/4
✓ Branch 0 taken 849 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 849 times.
849 if(it>=0&&it<MAXLEVELS)
2109 {
2110 849 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2111 }
2112 break;
2113 }
2114 return 0;
2115 }
2116
2117 default:
2118 //it=(1<<(it-1));
2119 /*if (item_type>=itype_max)
2120 {
2121 system_pal();
2122 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2123 game_pal();
2124
2125 return false;
2126 }*/
2127 int32_t itemid = getItemID(itemsbuf, item_type, it);
2128
2129 if(itemid == -1)
2130 return false;
2131
2132 return game->get_item(itemid);
2133 }
2134 7261 }
2135
2136
2137 22259 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2138 {
2139
9/9
✓ Branch 0 taken 1762 times.
✓ Branch 1 taken 8163 times.
✓ Branch 2 taken 1762 times.
✓ Branch 3 taken 1762 times.
✓ Branch 4 taken 1762 times.
✓ Branch 5 taken 1762 times.
✓ Branch 6 taken 1762 times.
✓ Branch 7 taken 1762 times.
✓ Branch 8 taken 1762 times.
22259 switch(item_type)
2140 {
2141 case itype_clock:
2142 {
2143 1762 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2144
2145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1762 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1762 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2146 return itemsbuf[maxid].fam_type;
2147
2148 1762 return has_item(itype_clock,1) ? 1 : 0;
2149 }
2150
2151 case itype_key:
2152 1762 return game->get_keys();
2153
2154 case itype_lkey:
2155 1762 return game->lvlkeys[get_dlevel()];
2156
2157 case itype_magiccontainer:
2158 1762 return game->get_maxmagic()/game->get_mp_per_block();
2159
2160 case itype_triforcepiece:
2161 {
2162 1762 int32_t count=0;
2163
2164
2/2
✓ Branch 0 taken 902144 times.
✓ Branch 1 taken 1762 times.
903906 for(int32_t i=0; i<MAXLEVELS; i++)
2165 {
2166 902144 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2167 902144 }
2168
2169 1762 return count;
2170 }
2171
2172 case itype_map:
2173 {
2174 1762 int32_t count=0;
2175
2176
2/2
✓ Branch 0 taken 902144 times.
✓ Branch 1 taken 1762 times.
903906 for(int32_t i=0; i<MAXLEVELS; i++)
2177 {
2178 902144 count+=(game->lvlitems[i]&liMAP)?1:0;
2179 902144 }
2180
2181 1762 return count;
2182 }
2183
2184 case itype_compass:
2185 {
2186 1762 int32_t count=0;
2187
2188
2/2
✓ Branch 0 taken 902144 times.
✓ Branch 1 taken 1762 times.
903906 for(int32_t i=0; i<MAXLEVELS; i++)
2189 {
2190 902144 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2191 902144 }
2192
2193 1762 return count;
2194 }
2195
2196 case itype_bosskey:
2197 {
2198 1762 int32_t count=0;
2199
2200
2/2
✓ Branch 0 taken 902144 times.
✓ Branch 1 taken 1762 times.
903906 for(int32_t i=0; i<MAXLEVELS; i++)
2201 {
2202 902144 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2203 902144 }
2204
2205 1762 return count;
2206 }
2207
2208 default:
2209 8163 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2210
2211
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 7653 times.
8163 if(maxid == -1)
2212 7653 return 0;
2213
2214 510 return itemsbuf[maxid].fam_type;
2215 }
2216 22259 }
2217
2218 20805 int32_t current_item(int32_t item_type) //item currently being used
2219 {
2220 20805 return current_item(item_type, true);
2221 }
2222
2223 29 std::map<int32_t, int32_t> itemcache;
2224
2225 // Not actually used by anything at the moment...
2226 void removeFromItemCache(int32_t itemid)
2227 {
2228 itemcache.erase(itemid);
2229 }
2230
2231 617 void flushItemCache()
2232 {
2233 617 itemcache.clear();
2234
2235 //also fix the active subscreen if items were deleted -DD
2236
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 if(game != NULL)
2237 {
2238 617 verifyBothWeapons();
2239 617 load_Sitems(&QMisc);
2240 617 }
2241 617 }
2242
2243 // This is used often, so it should be as direct as possible.
2244 1399809 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2245 {
2246
2/2
✓ Branch 0 taken 1392816 times.
✓ Branch 1 taken 6993 times.
1399809 if(jinx_check)
2247 {
2248
2/4
✓ Branch 0 taken 6993 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6993 times.
✗ Branch 3 not taken.
6993 if(!(HeroSwordClk() || HeroItemClk()))
2249 6993 jinx_check = false; //not jinxed
2250 6993 }
2251
3/4
✓ Branch 0 taken 1391971 times.
✓ Branch 1 taken 7838 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1391971 times.
1399809 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2252 {
2253 1391971 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2254
2255
2/2
✓ Branch 0 taken 1078479 times.
✓ Branch 1 taken 313492 times.
1391971 if(res != itemcache.end())
2256 1078479 return res->second;
2257 313492 }
2258
2259 321330 int32_t result = -1;
2260 321330 int32_t highestlevel = -1;
2261
2262
2/2
✓ Branch 0 taken 82260480 times.
✓ Branch 1 taken 321330 times.
82581810 for(int32_t i=0; i<MAXITEMS; i++)
2263 {
2264
5/6
✓ Branch 0 taken 6602124 times.
✓ Branch 1 taken 75658356 times.
✓ Branch 2 taken 14642 times.
✓ Branch 3 taken 6587482 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14642 times.
82260480 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2265 {
2266
4/4
✓ Branch 0 taken 13667 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 12198 times.
✓ Branch 3 taken 2444 times.
14642 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2267 {
2268 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2269
2/2
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 16 times.
2444 if(!checkmagiccost(i))
2270 {
2271
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2272 12 }
2273 2440 }
2274
1/6
✓ Branch 0 taken 14638 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14638 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2275 {
2276 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2277 continue;
2278 }
2279
2280
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 14368 times.
14638 if(itemsbuf[i].fam_type >= highestlevel)
2281 {
2282 14368 highestlevel = itemsbuf[i].fam_type;
2283 14368 result=i;
2284 14368 }
2285 14638 }
2286 82260476 }
2287
2288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 321330 times.
321330 if(!jinx_check) //Can't cache jinx_check results
2289 321330 itemcache[itemtype] = result;
2290 321330 return result;
2291 1399809 }
2292
2293 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2294 1399809 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2295 {
2296 1399809 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2297
2/2
✓ Branch 0 taken 6993 times.
✓ Branch 1 taken 1392816 times.
1399809 if(!jinx_check) //If not already a jinx-immune-only check...
2298 {
2299 //And the player IS jinxed...
2300
2/4
✓ Branch 0 taken 1392816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1392816 times.
1392816 if(HeroSwordClk() || HeroItemClk())
2301 {
2302 //Then do a jinx-immune-only check here
2303 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2304 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2305 //Should NOT need a compat rule, as this should always return -1 in old quests.
2306 if(ret2 > -1) return ret2;
2307 }
2308 1392816 }
2309 1399809 return ret;
2310 1399809 }
2311 7889 int32_t current_item_power(int32_t itemtype)
2312 {
2313 7889 int32_t result = current_item_id(itemtype,true);
2314
2/2
✓ Branch 0 taken 7312 times.
✓ Branch 1 taken 577 times.
7889 return (result<0) ? 0 : itemsbuf[result].power;
2315 }
2316
2317 int32_t heart_container_id()
2318 {
2319 for(int32_t i=0; i<MAXITEMS; i++)
2320 {
2321 if(itemsbuf[i].family == itype_heartcontainer)
2322 {
2323 return i;
2324 }
2325 }
2326 return -1;
2327 }
2328
2329 1762 int32_t item_tile_mod()
2330 {
2331 1762 int32_t tile=0;
2332
2333
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 99 times.
1762 if(game->get_bombs())
2334 {
2335 99 int32_t itemid = current_item_id(itype_bomb,false);
2336
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(itemid > -1 && checkbunny(itemid))
2337 99 tile+=itemsbuf[itemid].ltm;
2338 99 }
2339
2340
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 99 times.
1762 if(game->get_sbombs())
2341 {
2342 99 int32_t itemid = current_item_id(itype_sbomb,false);
2343
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(itemid > -1 && checkbunny(itemid))
2344 99 tile+=itemsbuf[itemid].ltm;
2345 99 }
2346
2347
1/2
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
1762 if(current_item(itype_clock))
2348 {
2349 int32_t itemid =
2350 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2351 ? iClock
2352 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2353 if(itemid > -1 && checkbunny(itemid))
2354 tile+=itemsbuf[itemid].ltm;
2355 }
2356
2357
1/2
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
1762 if(current_item(itype_key))
2358 {
2359 int32_t itemid =
2360 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2361 ? iKey
2362 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2363 if(itemid > -1 && checkbunny(itemid))
2364 tile+=itemsbuf[itemid].ltm;
2365 }
2366
2367
1/2
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
1762 if(current_item(itype_lkey))
2368 {
2369 int32_t itemid =
2370 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2371 ? iLevelKey
2372 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2373 if(itemid > -1 && checkbunny(itemid))
2374 tile+=itemsbuf[itemid].ltm;
2375 }
2376
2377
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 99 times.
1762 if(current_item(itype_map))
2378 {
2379 99 int32_t itemid =
2380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2381 ? iMap
2382 99 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2383
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(itemid > -1 && checkbunny(itemid))
2384 99 tile+=itemsbuf[itemid].ltm;
2385 99 }
2386
2387
1/2
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
1762 if(current_item(itype_compass))
2388 {
2389 int32_t itemid =
2390 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2391 ? iCompass
2392 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2393 if(itemid > -1 && checkbunny(itemid))
2394 tile+=itemsbuf[itemid].ltm;
2395 }
2396
2397
1/2
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
1762 if(current_item(itype_bosskey))
2398 {
2399 int32_t itemid =
2400 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2401 ? iBossKey
2402 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2403 if(itemid > -1 && checkbunny(itemid))
2404 tile+=itemsbuf[itemid].ltm;
2405 }
2406
2407
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 356 times.
1762 if(current_item(itype_magiccontainer))
2408 {
2409 356 int32_t itemid =
2410
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 200 times.
356 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2411 ? iMagicC
2412 200 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2413
2/4
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 356 times.
356 if(itemid > -1 && checkbunny(itemid))
2414 356 tile+=itemsbuf[itemid].ltm;
2415 356 }
2416
2417
1/2
✓ Branch 0 taken 1762 times.
✗ Branch 1 not taken.
1762 if(current_item(itype_triforcepiece))
2418 {
2419 int32_t itemid =
2420 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2421 ? iTriforce
2422 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2423 if(itemid > -1 && checkbunny(itemid))
2424 tile+=itemsbuf[itemid].ltm;
2425 }
2426
2427
2/2
✓ Branch 0 taken 1762 times.
✓ Branch 1 taken 902144 times.
903906 for(int32_t i=0; i<itype_max; i++)
2428 {
2429
2/2
✓ Branch 0 taken 273920 times.
✓ Branch 1 taken 628224 times.
902144 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2430 {
2431
2/2
✓ Branch 0 taken 12270 times.
✓ Branch 1 taken 615954 times.
628224 switch(i)
2432 {
2433 case itype_bomb:
2434 case itype_sbomb:
2435 case itype_clock:
2436 case itype_key:
2437 case itype_lkey:
2438 case itype_map:
2439 case itype_compass:
2440 case itype_bosskey:
2441 case itype_magiccontainer:
2442 case itype_triforcepiece:
2443 12270 continue; //already handled
2444 }
2445 615954 }
2446 889874 int32_t itemid = current_item_id(i,false);
2447
2/2
✓ Branch 0 taken 888112 times.
✓ Branch 1 taken 1762 times.
889874 if(i == itype_shield)
2448 1762 itemid = getCurrentShield(false);
2449
2450
3/4
✓ Branch 0 taken 10931 times.
✓ Branch 1 taken 878943 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10931 times.
889874 if(itemid < 0 || !checkbunny(itemid))
2451 878943 continue;
2452
2453 10931 itemdata const& itm = itemsbuf[itemid];
2454
2455
2/2
✓ Branch 0 taken 9224 times.
✓ Branch 1 taken 1707 times.
10931 switch(itm.family)
2456 {
2457 case itype_shield:
2458
1/2
✓ Branch 0 taken 1707 times.
✗ Branch 1 not taken.
1707 if(itm.flags & ITEM_FLAG9) //active shield
2459 {
2460 if(!usingActiveShield(itemid))
2461 {
2462 tile+=itm.misc6; //'Inactive PTM'
2463 continue;
2464 }
2465 }
2466 1707 break;
2467 }
2468
2469 10931 tile+=itm.ltm;
2470 10931 }
2471
2472 1762 return tile;
2473 }
2474
2475 1762 int32_t bunny_tile_mod()
2476 {
2477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1762 times.
1762 if(Hero.BunnyClock())
2478 {
2479 return game->get_bunny_ltm();
2480 }
2481 1762 return 0;
2482 1762 }
2483
2484 // Hints are drawn on a separate layer to combo reveals.
2485 void draw_lens_under(BITMAP *dest, bool layer)
2486 {
2487 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2488 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2489 //Lens flag 3: Don't show armos/chest/dive items
2490 //Lens flag 4: Show Raft Paths
2491 //Lens flag 5: Show Invisible Enemies
2492 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2493
2494 int32_t strike_hint_table[11]=
2495 {
2496 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2497 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2498 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2499 };
2500
2501 // int32_t page = tmpscr->cpage;
2502 {
2503 int32_t blink_rate=flash_reduction_enabled()?6:1;
2504 // int32_t temptimer=0;
2505 int32_t tempitem, tempweapon=0;
2506 strike_hint=strike_hint_table[strike_hint_counter];
2507
2508 if(strike_hint_timer>32)
2509 {
2510 strike_hint_timer=0;
2511 strike_hint_counter=((strike_hint_counter+1)%11);
2512 }
2513
2514 ++strike_hint_timer;
2515
2516 for(int32_t i=0; i<176; i++)
2517 {
2518 int32_t x = (i & 15) << 4;
2519 int32_t y = (i & 0xF0) + playing_field_offset;
2520 int32_t tempitemx=-16, tempitemy=-16;
2521 int32_t tempweaponx=-16, tempweapony=-16;
2522
2523 for(int32_t iter=0; iter<2; ++iter)
2524 {
2525 int32_t checkflag=0;
2526
2527 if(iter==0)
2528 {
2529 checkflag=combobuf[tmpscr->data[i]].flag;
2530 }
2531 else
2532 {
2533 checkflag=tmpscr->sflag[i];
2534 }
2535
2536 if(checkflag==mfSTRIKE)
2537 {
2538 if(!hints)
2539 {
2540 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2541 }
2542 else
2543 {
2544 checkflag = strike_hint;
2545 }
2546 }
2547
2548 switch(checkflag)
2549 {
2550 case 0:
2551 case mfZELDA:
2552 case mfPUSHED:
2553 case mfENEMY0:
2554 case mfENEMY1:
2555 case mfENEMY2:
2556 case mfENEMY3:
2557 case mfENEMY4:
2558 case mfENEMY5:
2559 case mfENEMY6:
2560 case mfENEMY7:
2561 case mfENEMY8:
2562 case mfENEMY9:
2563 case mfSINGLE:
2564 case mfSINGLE16:
2565 case mfNOENEMY:
2566 case mfTRAP_H:
2567 case mfTRAP_V:
2568 case mfTRAP_4:
2569 case mfTRAP_LR:
2570 case mfTRAP_UD:
2571 case mfNOGROUNDENEMY:
2572 case mfNOBLOCKS:
2573 case mfSCRIPT1:
2574 case mfSCRIPT2:
2575 case mfSCRIPT3:
2576 case mfSCRIPT4:
2577 case mfSCRIPT5:
2578 case mfSCRIPT6:
2579 case mfSCRIPT7:
2580 case mfSCRIPT8:
2581 case mfSCRIPT9:
2582 case mfSCRIPT10:
2583 case mfSCRIPT11:
2584 case mfSCRIPT12:
2585 case mfSCRIPT13:
2586 case mfSCRIPT14:
2587 case mfSCRIPT15:
2588 case mfSCRIPT16:
2589 case mfSCRIPT17:
2590 case mfSCRIPT18:
2591 case mfSCRIPT19:
2592 case mfSCRIPT20:
2593 case mfPITHOLE:
2594 case mfPITFALLFLOOR:
2595 case mfLAVA:
2596 case mfICE:
2597 case mfICEDAMAGE:
2598 case mfDAMAGE1:
2599 case mfDAMAGE2:
2600 case mfDAMAGE4:
2601 case mfDAMAGE8:
2602 case mfDAMAGE16:
2603 case mfDAMAGE32:
2604 case mfFREEZEALL:
2605 case mfFREZEALLANSFFCS:
2606 case mfFREEZEFFCSOLY:
2607 case mfSCRITPTW1TRIG:
2608 case mfSCRITPTW2TRIG:
2609 case mfSCRITPTW3TRIG:
2610 case mfSCRITPTW4TRIG:
2611 case mfSCRITPTW5TRIG:
2612 case mfSCRITPTW6TRIG:
2613 case mfSCRITPTW7TRIG:
2614 case mfSCRITPTW8TRIG:
2615 case mfSCRITPTW9TRIG:
2616 case mfSCRITPTW10TRIG:
2617 case mfTROWEL:
2618 case mfTROWELNEXT:
2619 case mfTROWELSPECIALITEM:
2620 case mfSLASHPOT:
2621 case mfLIFTPOT:
2622 case mfLIFTORSLASH:
2623 case mfLIFTROCK:
2624 case mfLIFTROCKHEAVY:
2625 case mfDROPITEM:
2626 case mfSPECIALITEM:
2627 case mfDROPKEY:
2628 case mfDROPLKEY:
2629 case mfDROPCOMPASS:
2630 case mfDROPMAP:
2631 case mfDROPBOSSKEY:
2632 case mfSPAWNNPC:
2633 case mfSWITCHHOOK:
2634 case mfSIDEVIEWLADDER:
2635 case mfSIDEVIEWPLATFORM:
2636 case mfNOENEMYSPAWN:
2637 case mfENEMYALL:
2638 case mfNOMIRROR:
2639 case mfUNSAFEGROUND:
2640 case mf168:
2641 case mf169:
2642 case mf170:
2643 case mf171:
2644 case mf172:
2645 case mf173:
2646 case mf174:
2647 case mf175:
2648 case mf176:
2649 case mf177:
2650 case mf178:
2651 case mf179:
2652 case mf180:
2653 case mf181:
2654 case mf182:
2655 case mf183:
2656 case mf184:
2657 case mf185:
2658 case mf186:
2659 case mf187:
2660 case mf188:
2661 case mf189:
2662 case mf190:
2663 case mf191:
2664 case mf192:
2665 case mf193:
2666 case mf194:
2667 case mf195:
2668 case mf196:
2669 case mf197:
2670 case mf198:
2671 case mf199:
2672 case mf200:
2673 case mf201:
2674 case mf202:
2675 case mf203:
2676 case mf204:
2677 case mf205:
2678 case mf206:
2679 case mf207:
2680 case mf208:
2681 case mf209:
2682 case mf210:
2683 case mf211:
2684 case mf212:
2685 case mf213:
2686 case mf214:
2687 case mf215:
2688 case mf216:
2689 case mf217:
2690 case mf218:
2691 case mf219:
2692 case mf220:
2693 case mf221:
2694 case mf222:
2695 case mf223:
2696 case mf224:
2697 case mf225:
2698 case mf226:
2699 case mf227:
2700 case mf228:
2701 case mf229:
2702 case mf230:
2703 case mf231:
2704 case mf232:
2705 case mf233:
2706 case mf234:
2707 case mf235:
2708 case mf236:
2709 case mf237:
2710 case mf238:
2711 case mf239:
2712 case mf240:
2713 case mf241:
2714 case mf242:
2715 case mf243:
2716 case mf244:
2717 case mf245:
2718 case mf246:
2719 case mf247:
2720 case mf248:
2721 case mf249:
2722 case mf250:
2723 case mf251:
2724 case mf252:
2725 case mf253:
2726 case mf254:
2727 case mfEXTENDED:
2728 break;
2729
2730 case mfPUSHUD:
2731 case mfPUSHLR:
2732 case mfPUSH4:
2733 case mfPUSHU:
2734 case mfPUSHD:
2735 case mfPUSHL:
2736 case mfPUSHR:
2737 case mfPUSHUDNS:
2738 case mfPUSHLRNS:
2739 case mfPUSH4NS:
2740 case mfPUSHUNS:
2741 case mfPUSHDNS:
2742 case mfPUSHLNS:
2743 case mfPUSHRNS:
2744 case mfPUSHUDINS:
2745 case mfPUSHLRINS:
2746 case mfPUSH4INS:
2747 case mfPUSHUINS:
2748 case mfPUSHDINS:
2749 case mfPUSHLINS:
2750 case mfPUSHRINS:
2751 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2752 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2753 {
2754 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2755 }
2756
2757 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2758 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2759 {
2760 if(hints)
2761 {
2762 switch(combobuf[tmpscr->data[i]].type)
2763 {
2764 case cPUSH_HEAVY:
2765 case cPUSH_HW:
2766 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2767 tempitemx=x, tempitemy=y;
2768
2769 if(tempitem>-1)
2770 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2771
2772 break;
2773
2774 case cPUSH_HEAVY2:
2775 case cPUSH_HW2:
2776 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2777 tempitemx=x, tempitemy=y;
2778
2779 if(tempitem>-1)
2780 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2781
2782 break;
2783 }
2784 }
2785 }
2786
2787 break;
2788
2789 case mfWHISTLE:
2790 if(hints)
2791 {
2792 tempitem=getItemID(itemsbuf,itype_whistle,1);
2793
2794 if(tempitem<0) break;
2795
2796 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2797 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2798 {
2799 tempitemx=x;
2800 tempitemy=y;
2801 }
2802
2803 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2804 }
2805
2806 break;
2807
2808 //Why is this here?
2809 case mfFAIRY:
2810 case mfMAGICFAIRY:
2811 case mfALLFAIRY:
2812 if(hints)
2813 {
2814 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2815
2816 if(tempitem < 0) break;
2817
2818 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2819 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2820 {
2821 tempitemx=x;
2822 tempitemy=y;
2823 }
2824
2825 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2826 }
2827
2828 break;
2829
2830 case mfBCANDLE:
2831 if(!hints)
2832 {
2833 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2834 }
2835 else
2836 {
2837 tempitem=getItemID(itemsbuf,itype_candle,1);
2838
2839 if(tempitem<0) break;
2840
2841 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2842 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2843 {
2844 tempitemx=x;
2845 tempitemy=y;
2846 }
2847
2848 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2849 }
2850
2851 break;
2852
2853 case mfRCANDLE:
2854 if(!hints)
2855 {
2856 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2857 }
2858 else
2859 {
2860 tempitem=getItemID(itemsbuf,itype_candle,2);
2861
2862 if(tempitem<0) break;
2863
2864 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2865 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2866 {
2867 tempitemx=x;
2868 tempitemy=y;
2869 }
2870
2871 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2872 }
2873
2874 break;
2875
2876 case mfWANDFIRE:
2877 if(!hints)
2878 {
2879 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2880 }
2881 else
2882 {
2883 tempitem=getItemID(itemsbuf,itype_wand,1);
2884
2885 if(tempitem<0) break;
2886
2887 tempweapon=wFire;
2888
2889 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2890 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2891 {
2892 tempitemx=x;
2893 tempitemy=y;
2894 }
2895 else
2896 {
2897 tempweaponx=x;
2898 tempweapony=y;
2899 }
2900
2901 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2902 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2903 }
2904
2905 break;
2906
2907 case mfDINSFIRE:
2908 if(!hints)
2909 {
2910 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2911 }
2912 else
2913 {
2914 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2915
2916 if(tempitem<0) break;
2917
2918 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2919 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2920 {
2921 tempitemx=x;
2922 tempitemy=y;
2923 }
2924
2925 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2926 }
2927
2928 break;
2929
2930 case mfARROW:
2931 if(!hints)
2932 {
2933 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2934 }
2935 else
2936 {
2937 tempitem=getItemID(itemsbuf,itype_arrow,1);
2938
2939 if(tempitem<0) break;
2940
2941 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2942 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2943 {
2944 tempitemx=x;
2945 tempitemy=y;
2946 }
2947
2948 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2949 }
2950
2951 break;
2952
2953 case mfSARROW:
2954 if(!hints)
2955 {
2956 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2957 }
2958 else
2959 {
2960 tempitem=getItemID(itemsbuf,itype_arrow,2);
2961
2962 if(tempitem<0) break;
2963
2964 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2965 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2966 {
2967 tempitemx=x;
2968 tempitemy=y;
2969 }
2970
2971 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2972 }
2973
2974 break;
2975
2976 case mfGARROW:
2977 if(!hints)
2978 {
2979 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2980 }
2981 else
2982 {
2983 tempitem=getItemID(itemsbuf,itype_arrow,3);
2984
2985 if(tempitem<0) break;
2986
2987 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2988 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2989 {
2990 tempitemx=x;
2991 tempitemy=y;
2992 }
2993
2994 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2995 }
2996
2997 break;
2998
2999 case mfBOMB:
3000 if(!hints)
3001 {
3002 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3003 }
3004 else
3005 {
3006 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3007 tempweapon = wLitBomb;
3008
3009 //if (tempitem<0) break;
3010 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3011 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3012 {
3013 tempweaponx=x;
3014 tempweapony=y;
3015 }
3016
3017 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3018 }
3019
3020 break;
3021
3022 case mfSBOMB:
3023 if(!hints)
3024 {
3025 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3026 }
3027 else
3028 {
3029 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3030 //if (tempitem<0) break;
3031 tempweapon = wLitSBomb;
3032
3033 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3034 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3035 {
3036 tempweaponx=x;
3037 tempweapony=y;
3038 }
3039
3040 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3041 }
3042
3043 break;
3044
3045 case mfARMOS_SECRET:
3046 if(!hints)
3047 {
3048 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3049 }
3050 break;
3051
3052 case mfBRANG:
3053 if(!hints)
3054 {
3055 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3056 }
3057 else
3058 {
3059 tempitem=getItemID(itemsbuf,itype_brang,1);
3060
3061 if(tempitem<0) break;
3062
3063 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3064 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3065 {
3066 tempitemx=x;
3067 tempitemy=y;
3068 }
3069
3070 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3071 }
3072
3073 break;
3074
3075 case mfMBRANG:
3076 if(!hints)
3077 {
3078 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3079 }
3080 else
3081 {
3082 tempitem=getItemID(itemsbuf,itype_brang,2);
3083
3084 if(tempitem<0) break;
3085
3086 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3087 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3088 {
3089 tempitemx=x;
3090 tempitemy=y;
3091 }
3092
3093 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3094 }
3095
3096 break;
3097
3098 case mfFBRANG:
3099 if(!hints)
3100 {
3101 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3102 }
3103 else
3104 {
3105 tempitem=getItemID(itemsbuf,itype_brang,3);
3106
3107 if(tempitem<0) break;
3108
3109 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3110 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3111 {
3112 tempitemx=x;
3113 tempitemy=y;
3114 }
3115
3116 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3117 }
3118
3119 break;
3120
3121 case mfWANDMAGIC:
3122 if(!hints)
3123 {
3124 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3125 }
3126 else
3127 {
3128 tempitem=getItemID(itemsbuf,itype_wand,1);
3129
3130 if(tempitem<0) break;
3131
3132 tempweapon=itemsbuf[tempitem].wpn3;
3133
3134 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3135 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3136 {
3137 tempitemx=x;
3138 tempitemy=y;
3139 }
3140 else
3141 {
3142 tempweaponx=x;
3143 tempweapony=y;
3144 --lens_hint_weapon[wMagic][4];
3145
3146 if(lens_hint_weapon[wMagic][4]<-8)
3147 {
3148 lens_hint_weapon[wMagic][4]=8;
3149 }
3150 }
3151
3152 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3153 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3154 }
3155
3156 break;
3157
3158 case mfREFMAGIC:
3159 if(!hints)
3160 {
3161 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3162 }
3163 else
3164 {
3165 tempitem=getItemID(itemsbuf,itype_shield,3);
3166
3167 if(tempitem<0) break;
3168
3169 tempweapon=ewMagic;
3170
3171 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3172 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3173 {
3174 tempitemx=x;
3175 tempitemy=y;
3176 }
3177 else
3178 {
3179 tempweaponx=x;
3180 tempweapony=y;
3181
3182 if(lens_hint_weapon[ewMagic][2]==up)
3183 {
3184 --lens_hint_weapon[ewMagic][4];
3185 }
3186 else
3187 {
3188 ++lens_hint_weapon[ewMagic][4];
3189 }
3190
3191 if(lens_hint_weapon[ewMagic][4]>8)
3192 {
3193 lens_hint_weapon[ewMagic][2]=up;
3194 }
3195
3196 if(lens_hint_weapon[ewMagic][4]<=0)
3197 {
3198 lens_hint_weapon[ewMagic][2]=down;
3199 }
3200 }
3201
3202 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3203 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3204 }
3205
3206 break;
3207
3208 case mfREFFIREBALL:
3209 if(!hints)
3210 {
3211 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3212 }
3213 else
3214 {
3215 tempitem=getItemID(itemsbuf,itype_shield,3);
3216
3217 if(tempitem<0) break;
3218
3219 tempweapon=ewFireball;
3220
3221 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3222 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3223 {
3224 tempitemx=x;
3225 tempitemy=y;
3226 tempweaponx=x;
3227 tempweapony=y;
3228 ++lens_hint_weapon[ewFireball][3];
3229
3230 if(lens_hint_weapon[ewFireball][3]>8)
3231 {
3232 lens_hint_weapon[ewFireball][3]=-8;
3233 lens_hint_weapon[ewFireball][4]=8;
3234 }
3235
3236 if(lens_hint_weapon[ewFireball][3]>0)
3237 {
3238 ++lens_hint_weapon[ewFireball][4];
3239 }
3240 else
3241 {
3242 --lens_hint_weapon[ewFireball][4];
3243 }
3244 }
3245
3246 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3247 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3248 }
3249
3250 break;
3251
3252 case mfSWORD:
3253 if(!hints)
3254 {
3255 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3256 }
3257 else
3258 {
3259 tempitem=getItemID(itemsbuf,itype_sword,1);
3260
3261 if(tempitem<0) break;
3262
3263 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3264 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3265 {
3266 tempitemx=x;
3267 tempitemy=y;
3268 }
3269
3270 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3271 }
3272
3273 break;
3274
3275 case mfWSWORD:
3276 if(!hints)
3277 {
3278 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3279 }
3280 else
3281 {
3282 tempitem=getItemID(itemsbuf,itype_sword,2);
3283
3284 if(tempitem<0) break;
3285
3286 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3287 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3288 {
3289 tempitemx=x;
3290 tempitemy=y;
3291 }
3292
3293 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3294 }
3295
3296 break;
3297
3298 case mfMSWORD:
3299 if(!hints)
3300 {
3301 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3302 }
3303 else
3304 {
3305 tempitem=getItemID(itemsbuf,itype_sword,3);
3306
3307 if(tempitem<0) break;
3308
3309 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3310 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3311 {
3312 tempitemx=x;
3313 tempitemy=y;
3314 }
3315
3316 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3317 }
3318
3319 break;
3320
3321 case mfXSWORD:
3322 if(!hints)
3323 {
3324 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3325 }
3326 else
3327 {
3328 tempitem=getItemID(itemsbuf,itype_sword,4);
3329
3330 if(tempitem<0) break;
3331
3332 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3333 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3334 {
3335 tempitemx=x;
3336 tempitemy=y;
3337 }
3338
3339 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3340 }
3341
3342 break;
3343
3344 case mfSWORDBEAM:
3345 if(!hints)
3346 {
3347 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3348 }
3349 else
3350 {
3351 tempitem=getItemID(itemsbuf,itype_sword,1);
3352
3353 if(tempitem<0) break;
3354
3355 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3356 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3357 {
3358 tempitemx=x;
3359 tempitemy=y;
3360 }
3361
3362 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3363 }
3364
3365 break;
3366
3367 case mfWSWORDBEAM:
3368 if(!hints)
3369 {
3370 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3371 }
3372 else
3373 {
3374 tempitem=getItemID(itemsbuf,itype_sword,2);
3375
3376 if(tempitem<0) break;
3377
3378 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3379 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3380 {
3381 tempitemx=x;
3382 tempitemy=y;
3383 }
3384
3385 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3386 }
3387
3388 break;
3389
3390 case mfMSWORDBEAM:
3391 if(!hints)
3392 {
3393 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3394 }
3395 else
3396 {
3397 tempitem=getItemID(itemsbuf,itype_sword,3);
3398
3399 if(tempitem<0) break;
3400
3401 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3402 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3403 {
3404 tempitemx=x;
3405 tempitemy=y;
3406 }
3407
3408 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3409 }
3410
3411 break;
3412
3413 case mfXSWORDBEAM:
3414 if(!hints)
3415 {
3416 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3417 }
3418 else
3419 {
3420 tempitem=getItemID(itemsbuf,itype_sword,4);
3421
3422 if(tempitem<0) break;
3423
3424 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3425 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3426 {
3427 tempitemx=x;
3428 tempitemy=y;
3429 }
3430
3431 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3432 }
3433
3434 break;
3435
3436 case mfHOOKSHOT:
3437 if(!hints)
3438 {
3439 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3440 }
3441 else
3442 {
3443 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3444
3445 if(tempitem<0) break;
3446
3447 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3448 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3449 {
3450 tempitemx=x;
3451 tempitemy=y;
3452 }
3453
3454 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3455 }
3456
3457 break;
3458
3459 case mfWAND:
3460 if(!hints)
3461 {
3462 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3463 }
3464 else
3465 {
3466 tempitem=getItemID(itemsbuf,itype_wand,1);
3467
3468 if(tempitem<0) break;
3469
3470 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3471 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3472 {
3473 tempitemx=x;
3474 tempitemy=y;
3475 }
3476
3477 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3478 }
3479
3480 break;
3481
3482 case mfHAMMER:
3483 if(!hints)
3484 {
3485 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3486 }
3487 else
3488 {
3489 tempitem=getItemID(itemsbuf,itype_hammer,1);
3490
3491 if(tempitem<0) break;
3492
3493 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3494 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3495 {
3496 tempitemx=x;
3497 tempitemy=y;
3498 }
3499
3500 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3501 }
3502
3503 break;
3504
3505 case mfARMOS_ITEM:
3506 case mfDIVE_ITEM:
3507 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3508 {
3509 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3510 }
3511 break;
3512
3513 case 16:
3514 case 17:
3515 case 18:
3516 case 19:
3517 case 20:
3518 case 21:
3519 case 22:
3520 case 23:
3521 case 24:
3522 case 25:
3523 case 26:
3524 case 27:
3525 case 28:
3526 case 29:
3527 case 30:
3528 case 31:
3529 if(!hints)
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3531 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3532
3533 break;
3534 case mfSECRETSNEXT:
3535 if(!hints)
3536 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3537 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3538
3539 break;
3540
3541 case mfSTRIKE:
3542 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3543 {
3544 goto special;
3545 }
3546 else
3547 {
3548 break;
3549 }
3550
3551 default: goto special;
3552
3553 special:
3554 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3555 {
3556 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3557 {
3558 rectfill(dest,x,y,x+15,y+15,WHITE);
3559 }
3560 }
3561
3562 break;
3563 }
3564 }
3565 }
3566
3567 if(layer)
3568 {
3569 if(tmpscr->door[0]==dWALK)
3570 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3571
3572 if(tmpscr->door[1]==dWALK)
3573 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3574
3575 if(tmpscr->door[2]==dWALK)
3576 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3577
3578 if(tmpscr->door[3]==dWALK)
3579 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3580
3581 if(tmpscr->door[0]==dBOMB)
3582 {
3583 showbombeddoor(dest, 0);
3584 }
3585
3586 if(tmpscr->door[1]==dBOMB)
3587 {
3588 showbombeddoor(dest, 1);
3589 }
3590
3591 if(tmpscr->door[2]==dBOMB)
3592 {
3593 showbombeddoor(dest, 2);
3594 }
3595
3596 if(tmpscr->door[3]==dBOMB)
3597 {
3598 showbombeddoor(dest, 3);
3599 }
3600 }
3601
3602 if(tmpscr->stairx + tmpscr->stairy)
3603 {
3604 if(!hints)
3605 {
3606 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3607 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3608 }
3609 else
3610 {
3611 if(tmpscr->flags&fWHISTLE)
3612 {
3613 tempitem=getItemID(itemsbuf,itype_whistle,1);
3614 int32_t tempitemx=-16;
3615 int32_t tempitemy=-16;
3616
3617 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3618 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3619 {
3620 tempitemx=tmpscr->stairx;
3621 tempitemy=tmpscr->stairy+playing_field_offset;
3622 }
3623
3624 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3625 }
3626 }
3627 }
3628 }
3629 }
3630
3631 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3632
3633 void draw_lens_over()
3634 {
3635 // Oh, what the heck.
3636 static BITMAP *lens_scr = NULL;
3637 static int32_t last_width = -1;
3638 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3639
3640 // Only redraw the circle if the size has changed
3641 if(width != last_width)
3642 {
3643 if(lens_scr == NULL)
3644 {
3645 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3646 }
3647
3648 clear_to_color(lens_scr, BLACK);
3649 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3650 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3651 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3652 last_width=width;
3653 }
3654
3655 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3656 }
3657
3658 //----------------------------------------------------------------
3659
3660 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3661 {
3662 //recreating a big bitmap every frame is highly sluggish.
3663 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3664 clear_to_color(wavebuf, BLACK);
3665 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3666
3667 int32_t ofs;
3668 // int32_t amplitude=8;
3669 // int32_t wavelength=4;
3670 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3671 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3672 int32_t amp2=168;
3673 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3674 int32_t i=frame%amp2;
3675
3676 for(int32_t j=0; j<168; j++)
3677 {
3678 if(j&1 && interpol)
3679 {
3680 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3681 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3682 }
3683 else
3684 {
3685 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3686 }
3687
3688 if(ofs)
3689 {
3690 for(int32_t k=0; k<256; k++)
3691 {
3692 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3693 }
3694 }
3695 }
3696 }
3697
3698 void draw_fuzzy(int32_t fuzz)
3699 // draws from right half of scrollbuf to framebuf
3700 {
3701 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3702 byte *start, *si, *di;
3703
3704 if(fuzz<1)
3705 fuzz = 1;
3706
3707 xstep = 128%fuzz;
3708
3709 if(xstep > 0)
3710 xstep = fuzz-xstep;
3711
3712 ystep = 112%fuzz;
3713
3714 if(ystep > 0)
3715 ystep = fuzz-ystep;
3716
3717 firsty = 1;
3718
3719 for(y=0; y<224;)
3720 {
3721 start = &(scrollbuf->line[y][256]);
3722
3723 for(dy=0; dy<ystep && dy+y<224; dy++)
3724 {
3725 si = start;
3726 di = &(framebuf->line[y+dy][0]);
3727 i = xstep;
3728 firstx = 1;
3729
3730 for(dx=0; dx<256; dx++)
3731 {
3732 *(di++) = *si;
3733
3734 if(++i >= fuzz)
3735 {
3736 if(!firstx)
3737 si += fuzz;
3738 else
3739 {
3740 si += fuzz-xstep;
3741 firstx = 0;
3742 }
3743
3744 i = 0;
3745 }
3746 }
3747 }
3748
3749 if(!firsty)
3750 y += fuzz;
3751 else
3752 {
3753 y += ystep;
3754 ystep = fuzz;
3755 firsty = 0;
3756 }
3757 }
3758 }
3759
3760 3562 void updatescr(bool allowwavy)
3761 {
3762
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3533 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
3562 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3763
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3533 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
3562 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3764
3765
1/2
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
3562 if(toogam)
3766 {
3767 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3768 }
3769
3770
1/2
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
3562 if(Showpal)
3771 dump_pal(framebuf);
3772
3773
1/2
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
3562 if(!Playing)
3774 black_opening_count=0;
3775
3776
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 1507 times.
3562 if(black_opening_count<0) //shape is opening up
3777 {
3778 1507 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3779
3780
2/4
✓ Branch 0 taken 1507 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1507 times.
1507 if(Advance||(!Paused))
3781 {
3782 1507 ++black_opening_count;
3783 1507 }
3784 1507 }
3785
1/2
✓ Branch 0 taken 2055 times.
✗ Branch 1 not taken.
2055 else if(black_opening_count>0) //shape is closing
3786 {
3787 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3788
3789 if(Advance||(!Paused))
3790 {
3791 --black_opening_count;
3792 }
3793 }
3794
3795
3/4
✓ Branch 0 taken 2077 times.
✓ Branch 1 taken 1485 times.
✓ Branch 2 taken 2077 times.
✗ Branch 3 not taken.
3562 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3796 {
3797 black_opening_shape = bosCIRCLE;
3798 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3799 refreshTints();
3800 refreshpal=true;
3801 }
3802
3803
2/2
✓ Branch 0 taken 3514 times.
✓ Branch 1 taken 48 times.
3562 if(refreshpal)
3804 {
3805 48 refreshpal=false;
3806 48 RAMpal[253] = _RGB(0,0,0);
3807 48 RAMpal[254] = _RGB(63,63,63);
3808 48 hw_palette = &RAMpal;
3809 48 update_hw_pal = true;
3810
3811 48 create_rgb_table(&rgb_table, RAMpal, NULL);
3812 48 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3813 48 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3814
3815
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 48 times.
12336 for(int32_t q=0; q<PAL_SIZE; q++)
3816 {
3817 12288 trans_table2.data[0][q] = q;
3818 12288 trans_table2.data[q][q] = q;
3819 12288 }
3820 48 }
3821
3822 3562 bool clearwavy = (wavy <= 0);
3823
3824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3562 times.
3562 if(wavy <= 0)
3825 {
3826 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3827 3562 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3828 3562 }
3829
3830 3562 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3831
3832
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3562 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3562 if(wavy && Playing && allowwavy)
3833 {
3834 draw_wavy(framebuf, wavybuf, wavy,false);
3835 }
3836
3837
1/2
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
3562 if(clearwavy)
3838 3562 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3839 else if(Playing && !Paused)
3840 wavy--; // Wavy was set by a script. Decrement it.
3841
3842
4/6
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122 times.
✓ Branch 3 taken 3440 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 122 times.
3562 if(Playing && msgpos && !screenscrolling)
3843 {
3844
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 if(!(msg_bg_display_buf->clip))
3845 122 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3846
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 if(!(msg_portrait_display_buf->clip))
3847 122 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3848
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 if(!(msg_txt_display_buf->clip))
3849 122 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3850 122 }
3851
3852 /*
3853 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3854 {
3855 BITMAP* subBmp = 0;
3856 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3857 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3858 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3859 destroy_bitmap(subBmp);
3860 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3861 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3862 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3863 }
3864 */
3865
3866
2/2
✓ Branch 0 taken 3212 times.
✓ Branch 1 taken 350 times.
3562 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3867
3868
2/2
✓ Branch 0 taken 3212 times.
✓ Branch 1 taken 350 times.
3562 if(nosubscr)
3869 {
3870 350 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3871 350 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3872 350 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3873 350 }
3874
3875 //TODO: Optimize blit 'overcalls' -Gleeok
3876
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 3212 times.
3562 BITMAP *source = nosubscr ? panorama : wavybuf;
3877 3562 blit(source,framebuf,0,0,0,0,256,224);
3878
3879 3562 update_hw_screen();
3880 3562 }
3881
3882 //----------------------------------------------------------------
3883
3884 PALETTE sys_pal;
3885
3886 int32_t onGUISnapshot()
3887 {
3888 char buf[200];
3889 int32_t num=0;
3890 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3891 do
3892 {
3893 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3894 }
3895 while(num<99999 && exists(buf));
3896
3897 BITMAP *b = create_bitmap_ex(8,resx,resy);
3898
3899 if(b)
3900 {
3901 if(MenuOpen)
3902 {
3903 //Cannot load game's palette while GUI elements are in focus. -Z
3904 //If there is a way to do this, then I have missed it.
3905 /*
3906 game_pal();
3907 RAMpal[253] = _RGB(0,0,0);
3908 RAMpal[254] = _RGB(63,63,63);
3909 set_palette_range(RAMpal,0,255,false);
3910 memcpy(RAMpal, snappal, sizeof(snappal));
3911 create_rgb_table(&rgb_table, RAMpal, NULL);
3912 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3913 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3914
3915 for(int32_t q=0; q<PAL_SIZE; q++)
3916 {
3917 trans_table2.data[0][q] = q;
3918 trans_table2.data[q][q] = q;
3919 }
3920 */
3921 //ringcolor(false);
3922 //get_palette(RAMpal);
3923 blit(screen,b,0,0,0,0,resx,resy);
3924 //al_trace("Menu Open\n");
3925 //game_pal();
3926 //PALETTE temppal;
3927 //get_palette(temppal);
3928 //system_pal();
3929 save_bitmap(buf,b,sys_pal);
3930 //save_bitmap(buf,b,RAMpal);
3931 //save_bitmap(buf,b,snappal);
3932 }
3933 else
3934 {
3935 blit(screen,b,0,0,0,0,resx,resy);
3936 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3937 }
3938 destroy_bitmap(b);
3939 }
3940
3941 return D_O_K;
3942 }
3943
3944 int32_t onNonGUISnapshot()
3945 {
3946 PALETTE temppal;
3947 get_palette(temppal);
3948 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3949
3950 char buf[200];
3951 int32_t num=0;
3952
3953 do
3954 {
3955 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3956 }
3957 while(num<99999 && exists(buf));
3958
3959 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3960
3961 return D_O_K;
3962 }
3963
3964 int32_t onSnapshot()
3965 {
3966 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3967 {
3968 onGUISnapshot();
3969 }
3970 else
3971 {
3972 onNonGUISnapshot();
3973 }
3974
3975 return D_O_K;
3976 }
3977
3978 int32_t onSaveMapPic()
3979 {
3980 int32_t mapres2 = 0;
3981 char buf[200];
3982 int32_t num=0;
3983 mapscr tmpscr_b[2];
3984 mapscr tmpscr_c[6];
3985 BITMAP* _screen_draw_buffer = NULL;
3986 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3987 set_clip_state(_screen_draw_buffer,1);
3988
3989 for(int32_t i=0; i<6; ++i)
3990 {
3991 tmpscr_c[i] = tmpscr2[i];
3992 tmpscr2[i].zero_memory();
3993
3994 if(i>=2)
3995 {
3996 continue;
3997 }
3998
3999 tmpscr_b[i] = tmpscr[i];
4000 tmpscr[i].zero_memory();
4001 }
4002
4003 do
4004 {
4005 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4006 }
4007 while(num<99999 && exists(buf));
4008
4009 BITMAP* mappic = NULL;
4010
4011
4012 bool done=false, redraw=true;
4013
4014 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4015
4016 if(!mappic)
4017 {
4018 system_pal();
4019 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4020 game_pal();
4021 return D_O_K;;
4022 }
4023
4024 // draw the map
4025 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4026
4027 for(int32_t y=0; y<8; y++)
4028 {
4029 for(int32_t x=0; x<16; x++)
4030 {
4031 if(!displayOnMap(x, y))
4032 {
4033 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4034 }
4035 else
4036 {
4037 int32_t s = (y<<4) + x;
4038 loadscr2(1,s,-1);
4039
4040 for(int32_t i=0; i<6; i++)
4041 {
4042 if(tmpscr[1].layermap[i]<=0)
4043 continue;
4044
4045 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4046 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4047 {
4048 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4049
4050 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4051 }
4052 }
4053
4054 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4055
4056 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4059 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4060
4061 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4062
4063 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4064 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4065 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4066 {
4067 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4068 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4069 }
4070 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4071
4072 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4073
4074 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4075 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4076 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4077 {
4078 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4080 }
4081 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4082 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4083
4084 }
4085
4086 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4087 }
4088 }
4089
4090 for(int32_t i=0; i<6; ++i)
4091 {
4092 tmpscr2[i]=tmpscr_c[i];
4093
4094 if(i>=2)
4095 {
4096 continue;
4097 }
4098
4099 tmpscr[i]=tmpscr_b[i];
4100 }
4101
4102 save_bitmap(buf,mappic,RAMpal);
4103 destroy_bitmap(mappic);
4104 destroy_bitmap(_screen_draw_buffer);
4105 return D_O_K;
4106 }
4107
4108 /*
4109 int32_t onSaveMapPic()
4110 {
4111 BITMAP* mappic = NULL;
4112 BITMAP* _screen_draw_buffer = NULL;
4113 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4114 int32_t mapres2 = 0;
4115 char buf[20];
4116 int32_t num=0;
4117 set_clip_state(_screen_draw_buffer,1);
4118 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4119
4120 do
4121 {
4122 sprintf(buf, "zelda%03d.png", ++num);
4123 }
4124 while(num<999 && exists(buf));
4125
4126 // if(!mappic) {
4127 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4128
4129 if(!mappic)
4130 {
4131 system_pal();
4132 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4133 game_pal();
4134 return D_O_K;
4135 }
4136
4137 // }
4138
4139 int32_t layermap, layerscreen;
4140 int32_t x2=0;
4141
4142 // draw the map
4143 for(int32_t y=0; y<8; y++)
4144 {
4145 for(int32_t x=0; x<16; x++)
4146 {
4147 int32_t s = (y<<4) + x;
4148
4149 if(!displayOnMap(x, y))
4150 {
4151 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4152 }
4153 else
4154 {
4155 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4156 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4157
4158 for(int32_t k=0; k<4; k++)
4159 {
4160 if(k==2)
4161 {
4162 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4163 }
4164
4165 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4166
4167 if(layermap>-1)
4168 {
4169 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4170
4171 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4172 {
4173 for(int32_t i=0; i<176; i++)
4174 {
4175 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4176 }
4177 }
4178 else
4179 {
4180 for(int32_t i=0; i<176; i++)
4181 {
4182 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4183 }
4184 }
4185 }
4186 }
4187
4188 for(int32_t i=0; i<176; i++)
4189 {
4190 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4191 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4192 {
4193 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4194 }
4195 }
4196
4197 for(int32_t k=4; k<6; k++)
4198 {
4199 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4200
4201 if(layermap>-1)
4202 {
4203 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4204
4205 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4206 {
4207 for(int32_t i=0; i<176; i++)
4208 {
4209 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4210 }
4211 }
4212 else
4213 {
4214 for(int32_t i=0; i<176; i++)
4215 {
4216 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4217 }
4218 }
4219 }
4220 }
4221 }
4222
4223 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4224 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4225 }
4226
4227 }
4228
4229 save_bitmap(buf,mappic,RAMpal);
4230 destroy_bitmap(mappic);
4231 destroy_bitmap(_screen_draw_buffer);
4232 return D_O_K;
4233 }
4234 */
4235
4236 void f_Quit(int32_t type)
4237 {
4238 if(type==qQUIT && !Playing)
4239 return;
4240
4241 bool from_menu = is_sys_pal;
4242
4243 if(!from_menu)
4244 {
4245 music_pause();
4246 pause_all_sfx();
4247 }
4248 enter_sys_pal();
4249 clear_keybuf();
4250
4251 if (replay_is_active() && replay_get_version() <= 9)
4252 replay_poll();
4253 if (replay_is_replaying())
4254 replay_peek_quit();
4255
4256 if (!replay_is_replaying())
4257 switch(type)
4258 {
4259 case qQUIT:
4260 onQuit();
4261 break;
4262
4263 case qRESET:
4264 onReset();
4265 break;
4266
4267 case qEXIT:
4268 onExit();
4269 break;
4270 }
4271
4272 if(Quit)
4273 {
4274 kill_sfx();
4275 music_stop();
4276 exit_sys_pal();
4277 update_hw_screen();
4278 }
4279 else
4280 {
4281 exit_sys_pal();
4282 if(!from_menu)
4283 {
4284 music_resume();
4285 resume_all_sfx();
4286 }
4287 }
4288
4289 if(!from_menu)
4290 show_mouse(NULL);
4291 eat_buttons();
4292
4293 zc_readrawkey(KEY_ESC);
4294
4295 zc_readrawkey(KEY_ENTER);
4296 }
4297
4298 //----------------------------------------------------------------
4299
4300 int32_t onNoWalls()
4301 {
4302 cheats_enqueue(Cheat::Walls);
4303 return D_O_K;
4304 }
4305
4306 int32_t onIgnoreSideview()
4307 {
4308 cheats_enqueue(Cheat::IgnoreSideView);
4309 return D_O_K;
4310 }
4311
4312 3542 int32_t input_idle(bool checkmouse)
4313 {
4314 static int32_t mx, my, mz, mb;
4315
4316
4/6
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441 times.
✓ Branch 3 taken 1101 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2441 times.
5983 if(keypressed() || zc_key_pressed() ||
4317
4/8
✓ Branch 0 taken 2441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2441 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2441 times.
✗ Branch 7 not taken.
2441 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4318 {
4319 1101 idle_count = 0;
4320
4321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1101 times.
1101 if(active_count < MAX_ACTIVE)
4322 {
4323 1101 ++active_count;
4324 1101 }
4325 1101 }
4326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2441 times.
2441 else if(idle_count < MAX_IDLE)
4327 {
4328 2441 ++idle_count;
4329 2441 active_count = 0;
4330 2441 }
4331
4332 3542 mx = mouse_x;
4333 3542 my = mouse_y;
4334 3542 mz = mouse_z;
4335 3542 mb = mouse_b;
4336
4337 3542 return idle_count;
4338 }
4339
4340 int32_t onGoFast()
4341 {
4342 cheats_enqueue(Cheat::Fast);
4343 return D_O_K;
4344 }
4345
4346 int32_t onKillCheat()
4347 {
4348 cheats_enqueue(Cheat::Kill);
4349 return D_O_K;
4350 }
4351
4352 int32_t onSecretsCheat()
4353 {
4354 cheats_enqueue(Cheat::TrigSecrets);
4355 return D_O_K;
4356 }
4357 int32_t onSecretsCheatPerm()
4358 {
4359 cheats_enqueue(Cheat::TrigSecretsPerm);
4360 return D_O_K;
4361 }
4362
4363 int32_t onShowLayer0()
4364 {
4365 show_layer_0 = !show_layer_0;
4366 return D_O_K;
4367 }
4368 int32_t onShowLayer1()
4369 {
4370 show_layer_1 = !show_layer_1;
4371 return D_O_K;
4372 }
4373 int32_t onShowLayer2()
4374 {
4375 show_layer_2 = !show_layer_2;
4376 return D_O_K;
4377 }
4378 int32_t onShowLayer3()
4379 {
4380 show_layer_3 = !show_layer_3;
4381 return D_O_K;
4382 }
4383 int32_t onShowLayer4()
4384 {
4385 show_layer_4 = !show_layer_4;
4386 return D_O_K;
4387 }
4388 int32_t onShowLayer5()
4389 {
4390 show_layer_5 = !show_layer_5;
4391 return D_O_K;
4392 }
4393 int32_t onShowLayer6()
4394 {
4395 show_layer_6 = !show_layer_6;
4396 return D_O_K;
4397 }
4398 int32_t onShowLayerO()
4399 {
4400 show_layer_over=!show_layer_over;
4401 return D_O_K;
4402 }
4403 int32_t onShowLayerP()
4404 {
4405 show_layer_push=!show_layer_push;
4406 return D_O_K;
4407 }
4408 int32_t onShowLayerS()
4409 {
4410 show_sprites=!show_sprites;
4411 return D_O_K;
4412 }
4413 int32_t onShowLayerF()
4414 {
4415 show_ffcs=!show_ffcs;
4416 return D_O_K;
4417 }
4418 int32_t onShowLayerW()
4419 {
4420 show_walkflags=!show_walkflags;
4421 if(show_walkflags)
4422 show_effectflags = false;
4423 return D_O_K;
4424 }
4425 int32_t onShowLayerE()
4426 {
4427 show_effectflags=!show_effectflags;
4428 if(show_effectflags)
4429 show_walkflags = false;
4430 return D_O_K;
4431 }
4432 int32_t onShowFFScripts()
4433 {
4434 show_ff_scripts=!show_ff_scripts;
4435 return D_O_K;
4436 }
4437 int32_t onShowHitboxes()
4438 {
4439 show_hitboxes=!show_hitboxes;
4440 return D_O_K;
4441 }
4442 int32_t onShowInfoOpacity()
4443 {
4444 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4445 zc_set_config("zc","debug_info_opacity",info_opacity);
4446 return D_O_K;
4447 }
4448
4449 int32_t onLightSwitch()
4450 {
4451 cheats_enqueue(Cheat::Light);
4452 return D_O_K;
4453 }
4454
4455 int32_t onGoTo();
4456 int32_t onGoToComplete();
4457
4458 3542 void syskeys()
4459 {
4460 3542 update_system_keys();
4461
4462 int32_t oldtitle_version;
4463
4464
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(close_button_quit)
4465 {
4466 close_button_quit=false;
4467 f_Quit(qEXIT);
4468 }
4469
4470 3542 poll_joystick();
4471
4472
2/10
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3542 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3542 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4473 {
4474 oldtitle_version=title_version;
4475 System();
4476 }
4477
4478 3542 mouse_down=gui_mouse_b();
4479
4480
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(zc_read_system_key(KEY_F1))
4481 {
4482 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4483 {
4484 halt=!halt;
4485 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4486 }
4487 else
4488 {
4489 Throttlefps=!Throttlefps;
4490 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4491 logic_counter=0;
4492 }
4493 }
4494
4495 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4496 /*
4497 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4498 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4499 */
4500
4501
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(zc_read_system_key(KEY_F2))
4502 {
4503 ShowFPS=!ShowFPS;
4504 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4505 }
4506
4507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3542 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4508
4509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3542 if(zc_read_system_key(KEY_F4) && Playing)
4510 {
4511 Paused=true;
4512 Advance=true;
4513 }
4514
4515
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(zc_read_system_key(KEY_F6)) onTryQuit();
4516
4517 #ifndef ALLEGRO_MACOSX
4518
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4519
4520
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4521 #else
4522 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4523
4524 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4525 #endif
4526
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3542 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4527
4528
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if (zc_read_system_key(KEY_F12))
4529 {
4530 onSnapshot();
4531 }
4532
4533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3542 if(debug_enabled && zc_read_system_key(KEY_TAB))
4534 set_debug(!get_debug());
4535
4536
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(CheatModifierKeys())
4537 {
4538 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4539 {
4540 if(!bindable_cheat(c))
4541 continue;
4542 if(get_debug() || cheat >= cheat_lvl(c))
4543 {
4544 if(checkcheat(c))
4545 cheats_hit_bind(c);
4546 }
4547 }
4548 }
4549
4550
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(volkeys)
4551 {
4552 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4553
4554 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4555
4556 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4557
4558 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4559 }
4560
4561
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3542 if(!get_debug() || !SystemKeys || replay_is_replaying())
4562 3542 goto bottom;
4563
4564 if(zc_readkey(KEY_D))
4565 {
4566 details = !details;
4567 rectfill(screen,0,0,319,7,BLACK);
4568 rectfill(screen,0,8,31,239,BLACK);
4569 rectfill(screen,288,8,319,239,BLACK);
4570 rectfill(screen,32,232,287,239,BLACK);
4571 }
4572
4573 if(zc_readkey(KEY_P)) Paused=!Paused;
4574
4575 //if(zc_readkey(KEY_P)) centerHero();
4576 if(zc_readkey(KEY_A))
4577 {
4578 Paused=true;
4579 Advance=true;
4580 }
4581
4582 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4583 #ifndef ALLEGRO_MACOSX
4584 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4585
4586 if(zc_readkey(KEY_F7))
4587 {
4588 Matrix(ss_speed, ss_density, 0);
4589 game_pal();
4590 }
4591 #else
4592 // The reason these are different on Mac in the first place is that
4593 // the OS doesn't let us use F9 and F10...
4594 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4595
4596 if(zc_readkey(KEY_F9))
4597 {
4598 Matrix(ss_speed, ss_density, 0);
4599 game_pal();
4600 }
4601 #endif
4602 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4603 {
4604 //change containers
4605 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4606 {
4607 //magic containers
4608 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4609 {
4610 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4611 }
4612 else
4613 {
4614 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4615 }
4616 }
4617 else
4618 {
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4622 }
4623 else
4624 {
4625 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4626 }
4627 }
4628 }
4629
4630 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4631 {
4632 //change containers
4633 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4634 {
4635 //magic containers
4636 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4637 {
4638 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4639 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4640 //heart containers
4641 }
4642 else
4643 {
4644 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4645 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4646 }
4647 }
4648 else
4649 {
4650 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4651 {
4652 game->set_magic(zc_max(game->get_magic()-1,0));
4653 }
4654 else
4655 {
4656 game->set_life(zc_max(game->get_life()-1,0));
4657 }
4658 }
4659 }
4660
4661 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4662
4663 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4664
4665 verifyBothWeapons();
4666
4667 bottom:
4668
4669
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(input_idle(true) > after_time())
4670 {
4671 Matrix(ss_speed, ss_density, 0);
4672 game_pal();
4673 }
4674 3542 }
4675
4676 310 void checkQuitKeys()
4677 {
4678 #ifndef ALLEGRO_MACOSX
4679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(key[KEY_F9]) f_Quit(qRESET);
4680
4681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(key[KEY_F10]) f_Quit(qEXIT);
4682 #else
4683 if(key[KEY_F7]) f_Quit(qRESET);
4684
4685 if(key[KEY_F8]) f_Quit(qEXIT);
4686 #endif
4687 310 }
4688
4689 3542 bool CheatModifierKeys()
4690 {
4691 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4692 // to trigger cheats.
4693
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if (replay_is_replaying())
4694 3542 return false;
4695
4696 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4697 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4698 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4699 {
4700 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4701 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4702 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4703 {
4704 return true;
4705 }
4706 }
4707 return false;
4708 3542 }
4709
4710 //99:05:54, for some reason?
4711 #define OLDMAXTIME 21405240
4712 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4713 #define MAXTIME 1944000000
4714
4715 3562 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4716 {
4717
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 392 times.
3562 if(zcmusic!=NULL)
4718 {
4719 392 zcmusic_poll();
4720 392 }
4721
4722 3562 updatescr(allowwavy);
4723
4724
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3562 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3562 times.
3562 while(Paused && !Advance && !Quit)
4725 {
4726 // have to call this, otherwise we'll get an infinite loop
4727 syskeys();
4728 if(allowF6Script)
4729 {
4730 FFCore.runF6Engine();
4731 }
4732 throttleFPS();
4733
4734 #ifdef _WIN32
4735
4736 if(use_dwm_flush)
4737 {
4738 do_DwmFlush();
4739 }
4740
4741 #endif
4742
4743 // to keep music playing
4744 if(zcmusic!=NULL)
4745 {
4746 zcmusic_poll();
4747 }
4748
4749 update_hw_screen();
4750 }
4751
4752
1/2
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
3562 if(Quit)
4753 return;
4754
4755
2/4
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3562 times.
3562 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4756 3562 game->change_time(1);
4757
4758 3562 Advance=false;
4759
4760
2/4
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3562 times.
3562 if (!replay_is_active() || replay_get_version() >= 11)
4761 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4762 down_control_states[i] = raw_control_state[i];
4763
4764
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3562 times.
3562 if (replay_is_active())
4765 {
4766
2/2
✓ Branch 0 taken 1380 times.
✓ Branch 1 taken 2182 times.
3562 if (replay_get_version() >= 3)
4767 2182 replay_poll();
4768
4769
5/6
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1862 times.
✓ Branch 3 taken 1680 times.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 1662 times.
3562 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4770 200 replay_peek_input();
4771 3542 }
4772
4773 3562 load_control_called_this_frame = false;
4774
4775 3562 poll_keyboard();
4776 3562 update_keys();
4777
4778 3562 ++frame;
4779
4780
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3542 times.
3562 if (replay_is_replaying())
4781 3542 replay_do_cheats();
4782 3562 syskeys();
4783
4784 // The mouse variables can change from the mouse thread at anytime during a frame,
4785 // so save the result at the start so that replaying is consistent.
4786 3562 script_mouse_x = gui_mouse_x();
4787 3562 script_mouse_y = gui_mouse_y();
4788 3562 script_mouse_z = mouse_z;
4789 3562 script_mouse_b = mouse_b;
4790
4791 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4792 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4793 // approach here means it doesn't matter which call adds the cheat.
4794 3562 cheats_execute_queued();
4795
4796
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3542 times.
3562 if (replay_is_replaying())
4797 3542 replay_peek_quit();
4798
1/2
✓ Branch 0 taken 3562 times.
✗ Branch 1 not taken.
3562 if (GameFlags & GAMEFLAG_TRYQUIT)
4799 replay_step_quit(0);
4800
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3542 times.
3562 if(allowF6Script)
4801 {
4802 3542 FFCore.runF6Engine();
4803 3542 }
4804
2/2
✓ Branch 0 taken 3559 times.
✓ Branch 1 taken 3 times.
3562 if (Quit)
4805 3 replay_step_quit(Quit);
4806 // Someday... maybe install a Turbo button here?
4807 3562 throttleFPS();
4808
4809 #ifdef _WIN32
4810
4811 if(use_dwm_flush)
4812 {
4813 do_DwmFlush();
4814 }
4815
4816 #endif
4817
4818 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4819
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3514 times.
3562 if(sfxcleanup)
4820 3514 sfx_cleanup();
4821 3562 }
4822
4823 void zapout()
4824 {
4825 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4826 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4827
4828 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4829 script_drawing_commands.Clear();
4830
4831 // zap out
4832 for(int32_t i=1; i<=24; i++)
4833 {
4834 draw_fuzzy(i);
4835 advanceframe(true);
4836
4837 if(Quit)
4838 {
4839 break;
4840 }
4841 }
4842 }
4843
4844 void zapin()
4845 {
4846 FFCore.warpScriptCheck();
4847 draw_screen(tmpscr);
4848 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4849 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4850 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4851
4852 // zap out
4853 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4854 for(int32_t i=24; i>=1; i--)
4855 {
4856 draw_fuzzy(i);
4857 advanceframe(true);
4858
4859 if(Quit)
4860 {
4861 break;
4862 }
4863 }
4864 }
4865
4866
4867 void wavyout(bool showhero)
4868 {
4869 draw_screen(tmpscr, showhero);
4870 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4871
4872 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4873 clear_to_color(wavebuf,0);
4874 blit(framebuf,wavebuf,0,0,16,0,256,224);
4875
4876 static PALETTE wavepal;
4877
4878 int32_t ofs;
4879 int32_t amplitude=8;
4880
4881 int32_t wavelength=4;
4882 double palpos=0, palstep=4, palstop=126;
4883
4884 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4885 for(int32_t i=0; i<168; i+=wavelength)
4886 {
4887 for(int32_t l=0; l<256; l++)
4888 {
4889 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4890 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4891 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4892 }
4893
4894 palpos+=palstep;
4895
4896 if(palpos>=0)
4897 {
4898 hw_palette = &wavepal;
4899 update_hw_pal = true;
4900 }
4901 else
4902 {
4903 hw_palette = &RAMpal;
4904 update_hw_pal = true;
4905 }
4906
4907 for(int32_t j=0; j+playing_field_offset<224; j++)
4908 {
4909 for(int32_t k=0; k<256; k++)
4910 {
4911 ofs=0;
4912
4913 if((j<i)&&(j&1))
4914 {
4915 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4916 }
4917
4918 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4919 }
4920 }
4921
4922 advanceframe(true);
4923
4924 // animate_combos();
4925 if(Quit)
4926 break;
4927 }
4928
4929 destroy_bitmap(wavebuf);
4930 }
4931
4932 void wavyin()
4933 {
4934 draw_screen(tmpscr);
4935 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4936
4937 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4938 clear_to_color(wavebuf,0);
4939 blit(framebuf,wavebuf,0,0,16,0,256,224);
4940
4941 static PALETTE wavepal;
4942
4943 //Breaks dark rooms.
4944 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4945 /*
4946 loadfullpal();
4947 loadlvlpal(DMaps[currdmap].color);
4948 ringcolor(false);
4949 */
4950 refreshpal=false;
4951 int32_t ofs;
4952 int32_t amplitude=8;
4953 int32_t wavelength=4;
4954 double palpos=168, palstep=4, palstop=126;
4955
4956 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4957 for(int32_t i=0; i<168; i+=wavelength)
4958 {
4959 for(int32_t l=0; l<256; l++)
4960 {
4961 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4962 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4963 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4964 }
4965
4966 palpos-=palstep;
4967
4968 if(palpos>=0)
4969 {
4970 hw_palette = &wavepal;
4971 update_hw_pal = true;
4972 }
4973 else
4974 {
4975 hw_palette = &RAMpal;
4976 update_hw_pal = true;
4977 }
4978
4979 for(int32_t j=0; j+playing_field_offset<224; j++)
4980 {
4981 for(int32_t k=0; k<256; k++)
4982 {
4983 ofs=0;
4984
4985 if((j<(167-i))&&(j&1))
4986 {
4987 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4988 }
4989
4990 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4991 }
4992 }
4993
4994 advanceframe(true);
4995 // animate_combos();
4996
4997 if(Quit)
4998 break;
4999 }
5000
5001 destroy_bitmap(wavebuf);
5002 }
5003
5004 3 void blackscr(int32_t fcnt,bool showsubscr)
5005 {
5006 3 reset_pal_cycling();
5007 3 script_drawing_commands.Clear();
5008
5009 3 FFCore.warpScriptCheck();
5010 3 bool showtime = game->should_show_time();
5011
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 90 times.
93 while(fcnt>0)
5012 {
5013 90 clear_bitmap(framebuf);
5014
5015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(showsubscr)
5016 {
5017 90 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5018
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
90 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5019 {
5020 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5021 }
5022 90 }
5023
5024 90 advanceframe(true);
5025
5026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(Quit)
5027 break;
5028
5029 90 --fcnt;
5030 }
5031 3 }
5032
5033 29 void openscreen(int32_t shape)
5034 {
5035 29 reset_pal_cycling();
5036 29 black_opening_count=0;
5037
5038
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
29 if(COOLSCROLL || shape>-1)
5039 {
5040 23 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5041 23 return;
5042 }
5043 else
5044 {
5045 6 Hero.setDontDraw(true);
5046 6 show_subscreen_dmap_dots=false;
5047 6 show_subscreen_numbers=false;
5048 // show_subscreen_items=false;
5049 6 show_subscreen_life=false;
5050 }
5051
5052 6 int32_t x=128;
5053
5054 6 FFCore.warpScriptCheck();
5055
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 480 times.
486 for(int32_t i=0; i<80; i++)
5056 {
5057 480 draw_screen(tmpscr);
5058 //? draw_screen already draws the subscreen -DD
5059 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5060 480 x=128-(((i*128/80)/8)*8);
5061
5062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(x>0)
5063 {
5064 480 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5065 480 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5066 480 }
5067
5068 480 advanceframe(true);
5069
5070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(Quit)
5071 {
5072 break;
5073 }
5074 480 }
5075
5076 6 Hero.setDontDraw(false);
5077 6 show_subscreen_items=true;
5078 6 show_subscreen_dmap_dots=true;
5079 29 }
5080
5081 void closescreen(int32_t shape)
5082 {
5083 reset_pal_cycling();
5084 black_opening_count=0;
5085
5086 if(COOLSCROLL || shape>-1)
5087 {
5088 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5089 return;
5090 }
5091 else
5092 {
5093 Hero.setDontDraw(true);
5094 show_subscreen_dmap_dots=false;
5095 show_subscreen_numbers=false;
5096 // show_subscreen_items=false;
5097 show_subscreen_life=false;
5098 }
5099
5100 int32_t x=128;
5101
5102 FFCore.warpScriptCheck();
5103 for(int32_t i=79; i>=0; --i)
5104 {
5105 draw_screen(tmpscr);
5106 //? draw_screen already draws the subscreen -DD
5107 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5108 x=128-(((i*128/80)/8)*8);
5109
5110 if(x>0)
5111 {
5112 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5113 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5114 }
5115
5116 advanceframe(true);
5117
5118 if(Quit)
5119 {
5120 break;
5121 }
5122 }
5123
5124 Hero.setDontDraw(false);
5125 show_subscreen_items=true;
5126 show_subscreen_dmap_dots=true;
5127 }
5128
5129 int32_t TriforceCount()
5130 {
5131 int32_t c=0;
5132
5133 for(int32_t i=1; i<=8; i++)
5134 if(game->lvlitems[i]&liTRIFORCE)
5135 ++c;
5136
5137 return c;
5138 }
5139
5140 int32_t onCustomGame()
5141 {
5142 int32_t file = getsaveslot();
5143
5144 if(file < 0)
5145 return D_O_K;
5146
5147 bool ret = (custom_game(file)!=0);
5148 return ret ? D_CLOSE : D_O_K;
5149 }
5150
5151 int32_t onContinue()
5152 {
5153 return D_CLOSE;
5154 }
5155
5156 int32_t onEsc() // Unused?? -L
5157 {
5158 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5159 }
5160
5161 int32_t onVsync()
5162 {
5163 Throttlefps = !Throttlefps;
5164 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5165 return D_O_K;
5166 }
5167
5168 int32_t onWinPosSave()
5169 {
5170 SaveWinPos = !SaveWinPos;
5171 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5172 return D_O_K;
5173 }
5174
5175 int32_t onClickToFreeze()
5176 {
5177 ClickToFreeze = !ClickToFreeze;
5178 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5179 return D_O_K;
5180 }
5181
5182 int32_t OnSaveZCConfig()
5183 {
5184 if(jwin_alert3(
5185 "Save Configuration",
5186 "Are you sure that you wish to save your present configuration settings?",
5187 "This will overwrite your prior settings!",
5188 NULL,
5189 "&Yes",
5190 "&No",
5191 NULL,
5192 'y',
5193 'n',
5194 0,
5195 lfont) == 1)
5196 {
5197 save_game_configs();
5198 return D_O_K;
5199 }
5200 else return D_O_K;
5201 }
5202
5203 int32_t OnnClearQuestDir()
5204 {
5205 if(jwin_alert3(
5206 "Clear Current Directory Cache",
5207 "Are you sure that you wish to clear the current cached directory?",
5208 "This will default the current directory to the ROOT for this instance of ZC Player!",
5209 NULL,
5210 "&Yes",
5211 "&No",
5212 NULL,
5213 'y',
5214 'n',
5215 0,
5216 lfont) == 1)
5217 {
5218 zc_set_config("zeldadx","win_qst_dir","");
5219 flush_config_file();
5220 strcpy(qstdir,"");
5221 #ifdef __EMSCRIPTEN__
5222 em_sync_fs();
5223 #endif
5224 return D_O_K;
5225 }
5226 else return D_O_K;
5227 }
5228
5229
5230 int32_t onConsoleZASM()
5231 {
5232 if ( !zasm_debugger )
5233 {
5234 AlertDialog("WARNING: ZASM Debugger",
5235 "Enabling this will open the ZASM Debugger Console"
5236 "\nThis will likely grind ZC to a halt with lag."
5237 "\nTo make any use of this, it is suggested that you read"
5238 "\nthe documentation for 'void Breakpoint(char[] string);'"
5239 " in 'ZScript_Additions.txt'"
5240 "\nThis is not recommended for normal users,"
5241 " and is only intended for ZC developers,"
5242 "\nor quest developers coding directly in ZASM"
5243 "\nAre you sure that you wish to open the ZASM Debugger?",
5244 [&](bool ret,bool)
5245 {
5246 if(ret)
5247 {
5248 FFCore.ZASMPrint(true);
5249 }
5250 }).show();
5251 return D_O_K;
5252 }
5253 else
5254 {
5255 FFCore.ZASMPrint(false);
5256 return D_O_K;
5257 }
5258 }
5259
5260
5261 int32_t onConsoleZScript()
5262 {
5263 if ( !zscript_debugger )
5264 {
5265 AlertDialog("ZScript Debugger",
5266 "Enabling this will open the ZScript Debugger Console"
5267 "\nThis will display any messages logged by scripts,"
5268 " including script errors."
5269 "\nAre you sure that you wish to open the ZScript Debugger?",
5270 [&](bool ret,bool)
5271 {
5272 if(ret)
5273 {
5274 FFCore.ZScriptConsole(true);
5275 }
5276 }).show();
5277 return D_O_K;
5278 }
5279 else
5280 {
5281 FFCore.ZScriptConsole(false);
5282 return D_O_K;
5283 }
5284 }
5285
5286 int32_t onClrConsoleOnLoad()
5287 {
5288 clearConsoleOnLoad = !clearConsoleOnLoad;
5289 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5290 return D_O_K;
5291 }
5292
5293
5294 int32_t onFrameSkip()
5295 {
5296 FrameSkip = !FrameSkip;
5297 return D_O_K;
5298 }
5299
5300 int32_t onSaveDragResize()
5301 {
5302 SaveDragResize = !SaveDragResize;
5303 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5304 return D_O_K;
5305 }
5306
5307 int32_t onDragAspect()
5308 {
5309 DragAspect = !DragAspect;
5310 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5311 return D_O_K;
5312 }
5313
5314 int32_t onTransLayers()
5315 {
5316 TransLayers = !TransLayers;
5317 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5318 return D_O_K;
5319 }
5320
5321 int32_t onNESquit()
5322 {
5323 NESquit = !NESquit;
5324 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5325 return D_O_K;
5326 }
5327
5328 int32_t onVolKeys()
5329 {
5330 volkeys = !volkeys;
5331 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5332 return D_O_K;
5333 }
5334
5335 int32_t onShowFPS()
5336 {
5337 ShowFPS = !ShowFPS;
5338 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5339 return D_O_K;
5340 }
5341
5342 417956 bool is_Fkey(int32_t k)
5343 {
5344
2/2
✓ Branch 0 taken 42504 times.
✓ Branch 1 taken 375452 times.
417956 switch(k)
5345 {
5346 case KEY_F1:
5347 case KEY_F2:
5348 case KEY_F3:
5349 case KEY_F4:
5350 case KEY_F5:
5351 case KEY_F6:
5352 case KEY_F7:
5353 case KEY_F8:
5354 case KEY_F9:
5355 case KEY_F10:
5356 case KEY_F11:
5357 case KEY_F12:
5358 42504 return true;
5359 }
5360
5361 375452 return false;
5362 417956 }
5363
5364 void kb_getkey(DIALOG *d);
5365
5366 //Used by all keyboard key settings dialogues.
5367 void kb_clearjoystick(DIALOG *d)
5368 {
5369 d->flags|=D_SELECTED;
5370
5371 scare_mouse();
5372 jwin_button_proc(MSG_DRAW,d,0);
5373 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5374 // text_mode(vc(11));
5375 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5376 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5377 unscare_mouse();
5378
5379 update_hw_screen(true);
5380
5381 clear_keybuf();
5382 int32_t k = next_press_key();
5383 clear_keybuf();
5384
5385 //shnarf
5386 //47=f1
5387 //59=esc
5388 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5389 // *((int32_t*)d->dp3) = k;
5390 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5391
5392
5393 d->flags&=~D_SELECTED;
5394 }
5395
5396 //Clears key to 0.
5397 //Used by all keyboard key settings dialogues.
5398 void kb_clearkey(DIALOG *d);
5399
5400 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5401 {
5402 switch(msg)
5403 {
5404 case MSG_KEY:
5405 case MSG_CLICK:
5406
5407 kb_clearjoystick(d);
5408
5409 while(gui_mouse_b())
5410 {
5411 clear_keybuf();
5412 rest(1);
5413 }
5414
5415 return D_REDRAW;
5416 }
5417
5418 return jwin_button_proc(msg,d,c);
5419 }
5420
5421 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5422 //Only used in keyboard settings dialogues to clear keys.
5423 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5424
5425 void j_getbtn(DIALOG *d)
5426 {
5427 d->flags|=D_SELECTED;
5428 scare_mouse();
5429 jwin_button_proc(MSG_DRAW,d,0);
5430 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5431 // text_mode(vc(11));
5432 int32_t y = gui_bmp->h/2 - 12;
5433 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5434 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5435 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5436 unscare_mouse();
5437
5438 update_hw_screen(true);
5439
5440 int32_t b = next_press_btn();
5441
5442 if(b>=0)
5443 *((int32_t*)d->dp3) = b;
5444
5445 d->flags&=~D_SELECTED;
5446
5447 if (player)
5448 player->joy_on = TRUE;
5449 }
5450
5451 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5452 {
5453 switch(msg)
5454 {
5455 case MSG_KEY:
5456 case MSG_CLICK:
5457
5458 j_getbtn(d);
5459
5460 while(gui_mouse_b()) {
5461 rest(1);
5462 clear_keybuf();
5463 }
5464
5465 return D_REDRAW;
5466 }
5467
5468 return jwin_button_proc(msg,d,c);
5469 }
5470
5471 //shnarf
5472 extern const char *key_str[];
5473 std::string get_keystr(int key);
5474
5475 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5476 //extern int32_t zcmusic_bufsz;
5477
5478 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5479 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5480
5481 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5482 {
5483 //these are here to bypass compiler warnings about unused arguments
5484 c=c;
5485
5486 if(msg==MSG_DRAW)
5487 {
5488 switch(d->w)
5489 {
5490 case 0:
5491 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5492 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5493 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5494 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5495 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5496 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5497 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5498 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5499 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5500 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5501 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5502 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5503 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5504 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5505 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5506 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5507 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5508 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5509 break;
5510
5511 case 1:
5512 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5513 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5514 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5515 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5516 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5517 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5518 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5519 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5520 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5521 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5522 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5523 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5524 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5525 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5526 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5527 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5528 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5529 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5530 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5531 break;
5532
5533 case 2:
5534 sprintf(str_a," %3d",midi_volume);
5535 sprintf(str_b," %3d",digi_volume);
5536 sprintf(str_l," %3d",emusic_volume);
5537 sprintf(str_m," %3dKB",zcmusic_bufsz);
5538 sprintf(str_r," %3d",sfx_volume);
5539 strcpy(str_s,pan_str[pan_style]);
5540 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5541 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5542 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5543 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5544 break;
5545 }
5546 }
5547
5548 return D_O_K;
5549 }
5550
5551 int32_t set_vol(void *dp3, int32_t d2)
5552 {
5553 switch(((int32_t*)dp3)[0])
5554 {
5555 case 0:
5556 midi_volume = zc_min(d2<<3,255);
5557 break;
5558
5559 case 1:
5560 digi_volume = zc_min(d2<<3,255);
5561 break;
5562
5563 case 2:
5564 emusic_volume = zc_min(d2<<3,255);
5565 break;
5566
5567 case 3:
5568 sfx_volume = zc_min(d2<<3,255);
5569 break;
5570 }
5571
5572 scare_mouse();
5573 // text_mode(vc(11));
5574 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5575 unscare_mouse();
5576 return D_O_K;
5577 }
5578
5579 int32_t set_pan(void *dp3, int32_t d2)
5580 {
5581 pan_style = vbound(d2,0,3);
5582 scare_mouse();
5583 // text_mode(vc(11));
5584 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5585 unscare_mouse();
5586 return D_O_K;
5587 }
5588
5589 int32_t set_buf(void *dp3, int32_t d2)
5590 {
5591 scare_mouse();
5592 // text_mode(vc(11));
5593 zcmusic_bufsz = d2 + 1;
5594 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5595 unscare_mouse();
5596 return D_O_K;
5597 }
5598
5599 static int32_t gamepad_btn_list[] =
5600 {
5601 6,
5602 7,8,9,10,11,12,13,14,15,16,17,
5603 18,19,20,21,22,23,24,25,26,27,28,
5604 29,30,31,32,33,34,35,36,37,38,39,
5605 -1
5606 };
5607
5608 static int32_t gamepad_dirs_list[] =
5609 {
5610 40,41,42,43,
5611 44,45,46,47,
5612 48,49,50,51,
5613 52,53,54,55,
5614 56,
5615 -1
5616 };
5617
5618 static TABPANEL gamepad_tabs[] =
5619 {
5620 // (text)
5621 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5622 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5623 { NULL, 0, NULL, 0, NULL }
5624 };
5625
5626 static DIALOG gamepad_dlg[] =
5627 {
5628 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5629 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5630 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5631 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5632 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5633 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5634 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5635 // 6
5636 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5637 // 7
5638 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5639 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5640 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5641 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5642 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5643 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5644 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5645 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5646 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5647 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5648 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5649 // 18
5650 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5651 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5652 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5653 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5654 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5655 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5656 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5657 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5658 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5659 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5660 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5661 // 29
5662 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5663 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5664 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5665 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5666 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5667 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5668 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5669 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5670 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5671 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5672 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5673 // 40
5674 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5675 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5676 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5677 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5678 // 44
5679 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5680 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5681 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5682 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5683 // 48
5684 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5685 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5686 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5687 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5688 // 52
5689 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5690 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5691 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5692 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5693 // 56
5694 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5695 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5696 };
5697
5698 static int32_t keyboard_keys_list[] =
5699 {
5700 6,7,8,9,10,
5701 11,12,13,14,15,16,17,18,19,20,
5702 21,22,23,24,25,26,27,28,29,30,
5703 31,32,33,34,35,36,37,38,39,40,
5704 -1
5705 };
5706
5707 static int32_t keyboard_dirs_list[] =
5708 {
5709 41,42,43,44,
5710 45,46,47,48,
5711 49,50,51,52,
5712 53,54,55,56,
5713 -1
5714 };
5715
5716 static int32_t keyboard_mods_list[] =
5717 {
5718 57,58,59,60,
5719 61,62,63,64,
5720 65,66,67,68,
5721 69,70,71,72,
5722 -1
5723 };
5724
5725 static TABPANEL keyboard_control_tabs[] =
5726 {
5727 // (text)
5728 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5729 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5730 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5731 { NULL, 0, NULL, 0, NULL }
5732 };
5733
5734 static DIALOG keyboard_control_dlg[] =
5735 {
5736 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5737 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5738 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5739 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5740 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5741 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5742 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5743 // Keys
5744 // 6
5745 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5746 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5747 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5748 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5749 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5750 // 11
5751 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5752 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5753 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5754 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5755 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5756 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5757 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5758 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5759 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5760 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5761 // 21
5762 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5763 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5764 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5765 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5766 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5767 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5768 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5769 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5770 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5771 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5772 // 31
5773 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5774 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5775 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5776 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5777 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5778 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5779 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5780 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5781 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5782 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5783 // Dirs
5784 // 41
5785 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5786 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5788 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5789 // 45
5790 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5791 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5792 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5793 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5794 // 49
5795 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5796 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5797 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5798 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5799 // 53
5800 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5801 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5802 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5803 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5804 // Mods
5805 // 57
5806 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5807 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5808 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5809 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5810 // 61
5811 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5812 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5813 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5814 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5815 // 65
5816 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5817 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5818 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5819 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5820 // 69
5821 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5822 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5823 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5824 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5825 // 73
5826 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5827 };
5828
5829 /*
5830 int32_t midi_dp[3] = {0,147,104};
5831 int32_t digi_dp[3] = {1,147,120};
5832 int32_t pan_dp[3] = {0,147,136};
5833 int32_t buf_dp[3] = {0,147,152};
5834 */
5835 int32_t midi_dp[3] = {0,0,0};
5836 int32_t digi_dp[3] = {1,0,0};
5837 int32_t emus_dp[3] = {2,0,0};
5838 int32_t buf_dp[3] = {0,0,0};
5839 int32_t sfx_dp[3] = {3,0,0};
5840 int32_t pan_dp[3] = {0,0,0};
5841
5842 static DIALOG sound_dlg[] =
5843 {
5844 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5845 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5846 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5847 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5848 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5849 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5850 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5851 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5852 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5853 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5854 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5855 // 10
5856 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5857 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5858 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5859 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5860 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5862 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5863 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5864 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5865 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5866 //20
5867 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5868 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5869 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5870 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5872 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5873 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5874 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5875 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5876 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5877 //30
5878 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5879 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5880 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5881 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 };
5883
5884 char zc_builddate[80];
5885 char zc_aboutstr[80];
5886
5887 static DIALOG about_dlg[] =
5888 {
5889 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5890 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5891 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5892 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5893 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5894 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5895 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5896 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5897 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5898 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5899 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5900 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5901 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5902 };
5903
5904
5905 static DIALOG quest_dlg[] =
5906 {
5907 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5908 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5909 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5910 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5911 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5912 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5913 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5914 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5915 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5916 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5917 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5918 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5919 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5920 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5921 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5923 };
5924
5925 static DIALOG triforce_dlg[] =
5926 {
5927 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5928 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5929 // 1
5930 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5931 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5932 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5933 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5934 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5935 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5936 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5937 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5938 // 9
5939 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5940 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5941 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5942 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5943 };
5944
5945 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5946 {
5947 go();
5948 int32_t ret=0;
5949 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5950 comeback();
5951 return ret != 0;
5952 }
5953
5954
5955 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5956 {
5957 if(def!=modulepath)
5958 strcpy(modulepath,def);
5959
5960 if(!usefilename)
5961 {
5962 int32_t i=(int32_t)strlen(modulepath);
5963
5964 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5965 modulepath[i--]=0;
5966 }
5967
5968 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5969 int32_t ret=0;
5970 int32_t sel=0;
5971
5972 if(list==NULL)
5973 {
5974 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5975 }
5976 else
5977 {
5978 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5979 }
5980
5981 return ret!=0;
5982 }
5983
5984 //The Dialogue that loads a ZMOD Module File
5985 int32_t zc_load_zmod_module_file()
5986 {
5987 if ( Playing )
5988 {
5989 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
5990 return -1;
5991 }
5992 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5993 return D_CLOSE;
5994
5995 FILE *tempmodule = fopen(modulepath,"r");
5996
5997 if(tempmodule == NULL)
5998 {
5999 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6000 return -1;
6001 }
6002
6003
6004 //Set the module path:
6005 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6006 strcpy(moduledata.module_name, modulepath);
6007 al_trace("New Module Path is: %s \n", moduledata.module_name);
6008 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6009 zcm.init(true); //Load the module values.
6010 moduledata.refresh_title_screen = 1;
6011 // refresh_select_screen = 1;
6012 build_biic_list();
6013 return D_O_K;
6014 }
6015
6016 static DIALOG module_info_dlg[] =
6017 {
6018 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6019
6020
6021 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6022 //1
6023 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6024 //2
6025 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6026 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6027 //4
6028 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6029 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6030 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6031 //7
6032
6033 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6034 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6035 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6036 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6037 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6039 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6040 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042
6043 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6044 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6045 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6046 };
6047
6048 void about_zcplayer_module(const char *prompt,int32_t initialval)
6049 {
6050
6051 module_info_dlg[0].dp2 = lfont;
6052 if ( moduledata.moduletitle[0] != 0 )
6053 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6054
6055 if ( moduledata.moduleauthor[0] != 0 )
6056 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6057
6058 if ( moduledata.moduleinfo0[0] != 0 )
6059 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6060 if ( moduledata.moduleinfo1[0] != 0 )
6061 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6062 if ( moduledata.moduleinfo2[0] != 0 )
6063 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6064 if ( moduledata.moduleinfo3[0] != 0 )
6065 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6066 if ( moduledata.moduleinfo4[0] != 0 )
6067 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6068
6069 char module_date[255];
6070 memset(module_date, 0, sizeof(module_date));
6071 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6072 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6073
6074
6075
6076 char module_vers[255];
6077 memset(module_vers, 0, sizeof(module_vers));
6078 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6079
6080
6081 //sprintf(tilecount,"%d",1);
6082
6083 char module_build[255];
6084 memset(module_build, 0, sizeof(module_build));
6085 if ( moduledata.modbeta )
6086 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6087 else
6088 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6089
6090 module_info_dlg[12].dp = (char*)module_date;
6091 module_info_dlg[13].dp = (char*)module_vers;
6092 module_info_dlg[14].dp = (char*)module_build;
6093
6094 large_dialog(module_info_dlg);
6095
6096 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6097 jwin_center_dialog(module_info_dlg);
6098
6099
6100 }
6101
6102 int32_t onAbout_ZCP_Module()
6103 {
6104 about_zcplayer_module("About Module (.zmod)", 0);
6105 return D_O_K;
6106 }
6107
6108 //New Modules Menu for 2.55+
6109 static MENU zcmodule_menu[] =
6110 {
6111 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6112 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6113
6114 { NULL, NULL, NULL, 0, NULL }
6115 };
6116
6117 int32_t onToggleRecordingNewSaves()
6118 {
6119 if (zc_get_config("zeldadx", "replay_new_saves", false))
6120 {
6121 zc_set_config("zeldadx", "replay_new_saves", false);
6122 }
6123 else
6124 {
6125 zc_set_config("zeldadx", "replay_new_saves", true);
6126 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6127 NULL,NULL,"OK",NULL,13,27,lfont);
6128 }
6129 return D_O_K;
6130 }
6131
6132 int32_t onToggleSnapshotAllFrames()
6133 {
6134 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6135 return D_O_K;
6136 }
6137
6138 int32_t onStopReplayOrRecord()
6139 {
6140 if (replay_is_replaying())
6141 {
6142 replay_quit();
6143 }
6144 else if (replay_get_mode() == ReplayMode::Record)
6145 {
6146 if (!replay_get_meta_bool("test_mode"))
6147 {
6148 jwin_alert("Recording", "You cannot stop recording a save file.",
6149 NULL,NULL,"OK",NULL,13,27,lfont);
6150 return D_CLOSE;
6151 }
6152
6153 if (jwin_alert("Stop Recording",
6154 "Save replay to disk and stop recording?",
6155 "This will stop the recording.",
6156 NULL,
6157 "Yes","No",13,27,lfont) != 1)
6158 return D_CLOSE;
6159
6160 replay_save();
6161 replay_stop();
6162 }
6163 return D_O_K;
6164 }
6165
6166 static int32_t handle_on_load_replay(ReplayMode mode)
6167 {
6168 if (Playing)
6169 {
6170 if (jwin_alert("Replay - Warning!",
6171 "Loading a replay will exit the current game.",
6172 "All unsaved progress will be lost.",
6173 "Do you wish to continue?",
6174 "Yes","No",13,27,lfont) != 1)
6175 return D_CLOSE;
6176 }
6177
6178 std::string mode_string = replay_mode_to_string(mode);
6179 mode_string[0] = std::toupper(mode_string[0]);
6180
6181 std::string line_1 = "Select a replay file to play back.";
6182 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6183 std::string line_3 = "You can stop the replay and take over manually any time.";
6184 if (mode == ReplayMode::Update)
6185 {
6186 line_1 = "Select a replay file to update.";
6187 line_2 = "WARNING: be sure to back up the zplay file";
6188 line_3 = "and verify that the updated replay works as expected!";
6189 }
6190
6191 if (jwin_alert(mode_string.c_str(),
6192 line_1.c_str(),
6193 line_2.c_str(),
6194 line_3.c_str(),
6195 "OK","Nevermind",13,27,lfont) == 1)
6196 {
6197 char replay_path[2048];
6198 strcpy(replay_path, "replays/");
6199 if (jwin_file_select_ex(
6200 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6201 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6202 return D_CLOSE;
6203
6204 replay_quit();
6205 load_replay_file_deferred(mode, replay_path);
6206 Quit = qRESET;
6207 return D_CLOSE;
6208 }
6209 return D_O_K;
6210 }
6211
6212 int32_t onLoadReplay()
6213 {
6214 return handle_on_load_replay(ReplayMode::Replay);
6215 }
6216
6217 int32_t onLoadReplayAssert()
6218 {
6219 return handle_on_load_replay(ReplayMode::Assert);
6220 }
6221
6222 int32_t onLoadReplayUpdate()
6223 {
6224 return handle_on_load_replay(ReplayMode::Update);
6225 }
6226
6227 int32_t onSaveReplay()
6228 {
6229 if (replay_get_mode() == ReplayMode::Record)
6230 {
6231 if (!replay_get_meta_bool("test_mode"))
6232 {
6233 if (jwin_alert("Save Replay",
6234 "This will save a copy of the replay up to this point.",
6235 "The official replay file will be untouched.",
6236 "Do you wish to continue?",
6237 "Yes","No",13,27,lfont) != 1)
6238 return D_CLOSE;
6239
6240 char replay_path[2048];
6241 strcpy(replay_path, replay_get_replay_path().string().c_str());
6242 if (jwin_file_select_ex(
6243 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6244 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6245 return D_CLOSE;
6246
6247 if (fileexists(replay_path))
6248 {
6249 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6250 NULL,NULL,"OK",NULL,13,27,lfont);
6251 return D_CLOSE;
6252 }
6253
6254 replay_save(replay_path);
6255 }
6256 else
6257 {
6258 replay_save();
6259 }
6260 }
6261 return D_O_K;
6262 }
6263
6264 static MENU replay_menu[] =
6265 {
6266 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6267 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6268 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6269 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6270 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6271 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6272 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6273
6274 { NULL, NULL, NULL, 0, NULL }
6275 };
6276
6277 static DIALOG credits_dlg[] =
6278 {
6279 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6280 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6281 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6282 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6283 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6284 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6285 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6286 };
6287
6288 29 static ListData dmap_list(dmaplist, &font);
6289
6290 static DIALOG goto_dlg[] =
6291 {
6292 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6293 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6294 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6295 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6296 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6297 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6298 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6299 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6300 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6301 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6302 };
6303
6304 int32_t onGoTo()
6305 {
6306 bool music = false;
6307 music = music;
6308 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6309
6310 goto_dlg[0].dp2=lfont;
6311 goto_dlg[4].d2=cheat_goto_dmap;
6312 goto_dlg[6].dp=cheat_goto_screen_str;
6313
6314 clear_keybuf();
6315
6316 large_dialog(goto_dlg);
6317
6318 if(zc_popup_dialog(goto_dlg,4)==1)
6319 {
6320 // dmap, screen
6321 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6322 };
6323
6324 return D_O_K;
6325 }
6326
6327 int32_t onGoToComplete()
6328 {
6329 if(!Playing)
6330 {
6331 return D_O_K;
6332 }
6333
6334 system_pal();
6335 music_pause();
6336 pause_all_sfx();
6337 show_mouse(screen);
6338 onGoTo();
6339 eat_buttons();
6340
6341 zc_readrawkey(KEY_ESC);
6342
6343 show_mouse(NULL);
6344 game_pal();
6345 music_resume();
6346 resume_all_sfx();
6347 return D_O_K;
6348 }
6349
6350 int32_t onCredits()
6351 {
6352 go();
6353
6354 BITMAP *win = create_bitmap_ex(8,222,110);
6355
6356 if(!win)
6357 return D_O_K;
6358
6359 int32_t c=0;
6360 int32_t l=0;
6361 int32_t ol=-1;
6362 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6363 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6364 PALETTE tmppal;
6365
6366 rti_gui.transparency_index = 1;
6367
6368 clear_to_color(win, rti_gui.transparency_index);
6369 draw_rle_sprite(win,rle,0,0);
6370 credits_dlg[0].dp2=lfont;
6371 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6372 credits_dlg[2].dp = win;
6373
6374 set_palette_range(black_palette,0,127,false);
6375
6376 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6377
6378 BITMAP* old_screen = screen;
6379 BITMAP* gui_bmp = zc_get_gui_bmp();
6380 ASSERT(gui_bmp);
6381 clear_to_color(gui_bmp, rti_gui.transparency_index);
6382 screen = gui_bmp;
6383
6384 while(update_dialog(p))
6385 {
6386 throttleFPS();
6387 ++c;
6388 l = zc_max((c>>1)-30,0);
6389
6390 if(l > rle->h)
6391 l = c = 0;
6392
6393 if(l > rle->h - 112)
6394 l = rle->h - 112;
6395
6396 clear_bitmap(win);
6397 draw_rle_sprite(win,rle,0,0-l);
6398
6399 if(c<=64)
6400 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6401
6402 set_palette_range(tmppal,0,127,false);
6403
6404 if(l!=ol)
6405 {
6406 scare_mouse();
6407 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6408 unscare_mouse();
6409 SCRFIX();
6410 ol=l;
6411 }
6412
6413 update_hw_screen();
6414 }
6415
6416 screen = old_screen;
6417 system_pal();
6418
6419 shutdown_dialog(p);
6420 destroy_bitmap(win);
6421 //comeback();
6422
6423 rti_gui.transparency_index = 0;
6424
6425 return D_O_K;
6426 }
6427
6428 const char *midilist(int32_t index, int32_t *list_size)
6429 {
6430 if(index<0)
6431 {
6432 *list_size=0;
6433
6434 for(int32_t i=0; i<MAXMIDIS; i++)
6435 if(tunes[i].data)
6436 ++(*list_size);
6437
6438 return NULL;
6439 }
6440
6441 int32_t i=0,m=0;
6442
6443 while(m<=index && i<=MAXMIDIS)
6444 {
6445 if(tunes[i].data)
6446 ++m;
6447
6448 ++i;
6449 }
6450
6451 --i;
6452
6453 if(i==MAXMIDIS && m<index)
6454 return "(null)";
6455
6456 return tunes[i].title;
6457 }
6458
6459 /* ------- MIDI info stuff -------- */
6460
6461 char *text;
6462 midi_info *zmi;
6463 bool dialog_running;
6464 bool listening;
6465
6466 void get_info(int32_t index);
6467
6468 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6469 {
6470 int32_t d2 = d->d2;
6471 int32_t ret = jwin_droplist_proc(msg,d,c);
6472
6473 if(d2!=d->d2)
6474 {
6475 get_info(d->d2);
6476 }
6477
6478 return ret;
6479 }
6480
6481 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6482 {
6483 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6484
6485 int32_t ret = jwin_button_proc(msg,d,c);
6486
6487 if(ret == D_CLOSE)
6488 {
6489 // get current midi index
6490 int32_t index = (d+(d->d1))->d2;
6491 int32_t i=0, m=0;
6492
6493 while(m<=index && i<=MAXMIDIS)
6494 {
6495 if(tunes[i].data)
6496 ++m;
6497
6498 ++i;
6499 }
6500
6501 --i;
6502 jukebox(i);
6503 listening = true;
6504 ret = D_O_K;
6505 }
6506
6507 return ret;
6508 }
6509
6510 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6511 {
6512 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6513
6514 int32_t ret = jwin_button_proc(msg,d,c);
6515
6516 if(ret == D_CLOSE)
6517 {
6518 // get current midi index
6519 int32_t index = (d+(d->d1))->d2;
6520 int32_t i=0, m=0;
6521
6522 while(m<=index && i<=MAXMIDIS)
6523 {
6524 if(tunes[i].data)
6525 ++m;
6526
6527 ++i;
6528 }
6529
6530 --i;
6531
6532 // get file name
6533
6534 int32_t sel=0;
6535 //struct ffblk f;
6536 char title[40] = "Save MIDI: ";
6537 char fname[2048];
6538 memset(fname,0,2048);
6539 static EXT_LIST list[] =
6540 {
6541 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6542 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6543 { NULL, NULL }
6544 };
6545
6546 strcpy(title+11, tunes[i].title);
6547 title[39] = '\0';
6548
6549 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6550 goto done;
6551
6552 if(exists(fname))
6553 {
6554 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6555 goto done;
6556 }
6557
6558 // save midi i
6559
6560 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6561 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6562
6563 done:
6564 chop_path(fname);
6565 ret = D_REDRAW;
6566 }
6567
6568 return ret;
6569 }
6570
6571 29 static ListData midi_list(midilist, &font);
6572
6573 static DIALOG midi_dlg[] =
6574 {
6575 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6576 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6577 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6578 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6579 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6580 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6581 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6582 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6583 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6584 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6585 };
6586
6587 void get_info(int32_t index)
6588 {
6589 int32_t i=0, m=0;
6590
6591 while(m<=index && i<=MAXMIDIS)
6592 {
6593 if(tunes[i].data)
6594 ++m;
6595
6596 ++i;
6597 }
6598
6599 --i;
6600
6601 if(i==MAXMIDIS && m<index)
6602 strcpy(text,"(null)");
6603 else
6604 {
6605 get_midi_info((MIDI*)tunes[i].data,zmi);
6606 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6607 }
6608
6609 midi_dlg[0].dp2=lfont;
6610 midi_dlg[3].dp = text;
6611 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6612 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6613
6614 if(dialog_running)
6615 {
6616 scare_mouse();
6617 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6618 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6619 unscare_mouse();
6620 }
6621 }
6622
6623 int32_t onMIDICredits()
6624 {
6625 text = (char*)malloc(4096);
6626 zmi = (midi_info*)malloc(sizeof(midi_info));
6627
6628 if(!text || !zmi)
6629 {
6630 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6631 return D_O_K;
6632 }
6633
6634 bool do_pause_midi = midi_pos >= 0 && currmidi;
6635 auto restore_midi = currmidi;
6636 if(do_pause_midi)
6637 {
6638 paused_midi_pos = midi_pos;
6639 stop_midi();
6640 midi_paused=true;
6641 midi_suspended = midissuspHALTED;
6642 }
6643
6644 midi_dlg[0].dp2=lfont;
6645 midi_dlg[2].d1 = 0;
6646 midi_dlg[2].d2 = 0;
6647 midi_dlg[4].flags = D_EXIT;
6648 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6649
6650 listening = false;
6651 dialog_running=false;
6652 get_info(0);
6653
6654 dialog_running=true;
6655
6656 large_dialog(midi_dlg);
6657
6658 zc_popup_dialog(midi_dlg,0);
6659 dialog_running=false;
6660
6661 if(listening)
6662 music_stop();
6663
6664 if(do_pause_midi)
6665 {
6666 midi_suspended = midissuspRESUME;
6667 currmidi = restore_midi;
6668 midi_pos = paused_midi_pos;
6669 }
6670
6671 if(text) free(text);
6672 if(zmi) free(zmi);
6673 return D_O_K;
6674 }
6675
6676 int32_t onAbout()
6677 {
6678 char buf1[80]={0};
6679 std::ostringstream oss;
6680 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6681 oss << buf1 << '\n';
6682 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6683 oss << buf1 << '\n';
6684 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6685 oss << buf1 << '\n';
6686 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6687 oss << buf1 << '\n';
6688 sprintf(buf1, "Tag: %s", getReleaseTag());
6689 oss << buf1 << '\n';
6690
6691 InfoDialog("About ZC", oss.str()).show();
6692 return D_O_K;
6693 }
6694
6695 int32_t onQuest()
6696 {
6697 char fname[100];
6698 strcpy(fname, get_filename(qstpath));
6699 quest_dlg[0].dp2=lfont;
6700 quest_dlg[1].dp = fname;
6701
6702 if(QHeader.quest_number==0)
6703 sprintf(str_a,"Custom");
6704 else
6705 sprintf(str_a,"%d",QHeader.quest_number);
6706
6707 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6708
6709 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6710 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6711
6712 large_dialog(quest_dlg);
6713
6714 zc_popup_dialog(quest_dlg, 0);
6715 return D_O_K;
6716 }
6717
6718 void call_vidmode_dlg();
6719 int32_t onVidMode()
6720 {
6721 call_vidmode_dlg();
6722 return D_O_K;
6723 }
6724
6725 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6726 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6727 //Added an extra statement, so that if the key is cleared to 0, the cleared
6728 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6729
6730 void load_ukeys(int32_t* arr)
6731 {
6732 arr[ukey_a] = Akey;
6733 arr[ukey_b] = Bkey;
6734 arr[ukey_s] = Skey;
6735 arr[ukey_l] = Lkey;
6736 arr[ukey_r] = Rkey;
6737 arr[ukey_p] = Pkey;
6738 arr[ukey_ex1] = Exkey1;
6739 arr[ukey_ex2] = Exkey2;
6740 arr[ukey_ex3] = Exkey3;
6741 arr[ukey_ex4] = Exkey4;
6742 arr[ukey_du] = DUkey;
6743 arr[ukey_dd] = DDkey;
6744 arr[ukey_dl] = DLkey;
6745 arr[ukey_dr] = DRkey;
6746 arr[ukey_mod1a] = cheat_modifier_keys[0];
6747 arr[ukey_mod1b] = cheat_modifier_keys[1];
6748 arr[ukey_mod2a] = cheat_modifier_keys[2];
6749 arr[ukey_mod2b] = cheat_modifier_keys[3];
6750 };
6751
6752 static const char* ukey_names[] = {
6753 "A", "B", "Start", "L", "R", "Map",
6754 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6755 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6756 "Cheat Mod R1", "Cheat Mod R2",
6757 };
6758 std::string get_ukey_name(int32_t k)
6759 {
6760 if (k < num_ukey) return ukey_names[k];
6761 return "";
6762 }
6763
6764 int32_t onKeyboard()
6765 {
6766 int32_t a = Akey;
6767 int32_t b = Bkey;
6768 int32_t s = Skey;
6769 int32_t l = Lkey;
6770 int32_t r = Rkey;
6771 int32_t p = Pkey;
6772 int32_t ex1 = Exkey1;
6773 int32_t ex2 = Exkey2;
6774 int32_t ex3 = Exkey3;
6775 int32_t ex4 = Exkey4;
6776 int32_t du = DUkey;
6777 int32_t dd = DDkey;
6778 int32_t dl = DLkey;
6779 int32_t dr = DRkey;
6780 int32_t mod1a = cheat_modifier_keys[0];
6781 int32_t mod1b = cheat_modifier_keys[1];
6782 int32_t mod2a = cheat_modifier_keys[2];
6783 int32_t mod2b = cheat_modifier_keys[3];
6784 bool done=false;
6785 int32_t ret;
6786
6787 keyboard_control_dlg[0].dp2=lfont;
6788
6789 large_dialog(keyboard_control_dlg);
6790
6791 while(!done)
6792 {
6793 ret = zc_popup_dialog(keyboard_control_dlg,3);
6794
6795 if(ret==3) // OK
6796 {
6797 int32_t ukeys[num_ukey];
6798 load_ukeys(ukeys);
6799 std::vector<std::string> uniqueError;
6800 for(int32_t q = 0; q < num_ukey; ++q)
6801 {
6802 for(int32_t p = q+1; p < num_ukey; ++p)
6803 {
6804 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6805 {
6806 char buf[64];
6807 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6808 std::string str(buf);
6809 uniqueError.push_back(str);
6810 }
6811 }
6812 }
6813 if(uniqueError.size() == 0)
6814 {
6815 done = true;
6816 save_control_configs(true);
6817 }
6818 else
6819 {
6820 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6821 box_out("Cannot have duplicate keybinds!"); box_eol();
6822 for(std::vector<std::string>::iterator it = uniqueError.begin();
6823 it != uniqueError.end(); ++it)
6824 {
6825 box_out((*it).c_str()); box_eol();
6826 }
6827 box_end(true);
6828 }
6829 }
6830 else // Cancel
6831 {
6832 Akey = a;
6833 Bkey = b;
6834 Skey = s;
6835 Lkey = l;
6836 Rkey = r;
6837 Pkey = p;
6838 Exkey1 = ex1;
6839 Exkey2 = ex2;
6840 Exkey3 = ex3;
6841 Exkey4 = ex4;
6842 DUkey = du;
6843 DDkey = dd;
6844 DLkey = dl;
6845 DRkey = dr;
6846 cheat_modifier_keys[0] = mod1a;
6847 cheat_modifier_keys[1] = mod1b;
6848 cheat_modifier_keys[2] = mod2a;
6849 cheat_modifier_keys[3] = mod2b;
6850
6851 done=true;
6852 }
6853
6854 rest(1);
6855 }
6856
6857 return D_O_K;
6858 }
6859
6860 int32_t onGamepad()
6861 {
6862 int32_t a = Abtn;
6863 int32_t b = Bbtn;
6864 int32_t s = Sbtn;
6865 int32_t l = Lbtn;
6866 int32_t r = Rbtn;
6867 int32_t m = Mbtn;
6868 int32_t p = Pbtn;
6869 int32_t ex1 = Exbtn1;
6870 int32_t ex2 = Exbtn2;
6871 int32_t ex3 = Exbtn3;
6872 int32_t ex4 = Exbtn4;
6873 int32_t up = DUbtn;
6874 int32_t down = DDbtn;
6875 int32_t left = DLbtn;
6876 int32_t right = DRbtn;
6877
6878 gamepad_dlg[0].dp2=lfont;
6879 if(analog_movement)
6880 gamepad_dlg[56].flags|=D_SELECTED;
6881 else
6882 gamepad_dlg[56].flags&=~D_SELECTED;
6883
6884 large_dialog(gamepad_dlg);
6885
6886 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6887
6888 if(ret == 4) //OK
6889 {
6890 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6891 save_control_configs(false);
6892 }
6893 else //Cancel
6894 {
6895 Abtn = a;
6896 Bbtn = b;
6897 Sbtn = s;
6898 Lbtn = l;
6899 Rbtn = r;
6900 Mbtn = m;
6901 Pbtn = p;
6902 Exbtn1 = ex1;
6903 Exbtn2 = ex2;
6904 Exbtn3 = ex3;
6905 Exbtn4 = ex4;
6906 DUbtn = up;
6907 DDbtn = down;
6908 DLbtn = left;
6909 DRbtn = right;
6910 }
6911
6912 return D_O_K;
6913 }
6914
6915 int32_t onCheatKeys()
6916 {
6917 int32_t oldcheats[Cheat::Last][2];
6918 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6919
6920 bool done=false;
6921
6922 while(!done)
6923 {
6924 bool confirm = false;
6925 CheatKeysDialog(&confirm).show();
6926 if(confirm) // OK
6927 {
6928 std::vector<std::string> uniqueError;
6929 char buf[512];
6930 for(size_t q = 1; q < Cheat::Last; ++q)
6931 {
6932 if(cheatkeys[q][1] && !cheatkeys[q][0])
6933 {
6934 cheatkeys[q][0] = cheatkeys[q][1];
6935 cheatkeys[q][1] = 0;
6936 }
6937 }
6938 for(size_t q = 1; q < Cheat::Last; ++q)
6939 {
6940 if(!bindable_cheat((Cheat)q)) continue;
6941 for(size_t p = q+1; p < Cheat::Last; ++p)
6942 {
6943 if(!bindable_cheat((Cheat)p)) continue;
6944 for(size_t q2 = 0; q2 <= 1; ++q2)
6945 for(size_t p2 = 0; p2 <= 1; ++p2)
6946 {
6947 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6948 {
6949 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6950 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6951 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6952 get_keystr(cheatkeys[q][q2])));
6953 }
6954 }
6955 }
6956 }
6957 if(uniqueError.size() == 0)
6958 {
6959 done = true;
6960 save_cheatkeys();
6961 }
6962 else
6963 {
6964 box_start(1, "Duplicate Keys", lfont, sfont, false, 500,400, 2);
6965 box_out("Cannot have duplicate keybinds!"); box_eol();
6966 for(std::vector<std::string>::iterator it = uniqueError.begin();
6967 it != uniqueError.end(); ++it)
6968 {
6969 box_out((*it).c_str()); box_eol();
6970 }
6971 box_end(true);
6972 }
6973 }
6974 else // Cancel
6975 {
6976 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6977 done=true;
6978 }
6979 rest(1);
6980 }
6981
6982 return D_O_K;
6983 }
6984
6985 int32_t onSound()
6986 {
6987 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6988 {
6989 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6990 }
6991 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6992 {
6993 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6994 }
6995 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6996 {
6997 emusic_volume = (int32_t)FFCore.usr_music_volume;
6998 }
6999 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7000 {
7001 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7002 }
7003 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7004 {
7005 pan_style = (int32_t)FFCore.usr_panstyle;
7006 }
7007
7008 int32_t m = midi_volume;
7009 int32_t d = digi_volume;
7010 int32_t e = emusic_volume;
7011 int32_t b = zcmusic_bufsz;
7012 int32_t s = sfx_volume;
7013 int32_t p = pan_style;
7014 pan_style = vbound(pan_style,0,3);
7015
7016 sound_dlg[0].dp2=lfont;
7017
7018 large_dialog(sound_dlg);
7019
7020 midi_dp[1] = sound_dlg[6].x;
7021 midi_dp[2] = sound_dlg[6].y;
7022 digi_dp[1] = sound_dlg[7].x;
7023 digi_dp[2] = sound_dlg[7].y;
7024 emus_dp[1] = sound_dlg[8].x;
7025 emus_dp[2] = sound_dlg[8].y;
7026 buf_dp[1] = sound_dlg[9].x;
7027 buf_dp[2] = sound_dlg[9].y;
7028 sfx_dp[1] = sound_dlg[10].x;
7029 sfx_dp[2] = sound_dlg[10].y;
7030 pan_dp[1] = sound_dlg[11].x;
7031 pan_dp[2] = sound_dlg[11].y;
7032 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7033 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7034 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7035 sound_dlg[18].d2 = zcmusic_bufsz;
7036 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7037 sound_dlg[20].d2 = pan_style;
7038
7039 int32_t ret = zc_popup_dialog(sound_dlg,1);
7040
7041 if(ret==2)
7042 {
7043 master_volume(digi_volume,midi_volume);
7044
7045 for(int32_t i=0; i<WAV_COUNT; ++i)
7046 {
7047 //allegro assertion fails when passing in -1 as voice -DD
7048 if(sfx_voice[i] > 0)
7049 voice_set_volume(sfx_voice[i], sfx_volume);
7050 }
7051 zc_set_config(sfx_sect,"digi",digi_volume);
7052 zc_set_config(sfx_sect,"midi",midi_volume);
7053 zc_set_config(sfx_sect,"sfx",sfx_volume);
7054 zc_set_config(sfx_sect,"emusic",emusic_volume);
7055 zc_set_config(sfx_sect,"pan",pan_style);
7056 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7057 }
7058 else
7059 {
7060 midi_volume = m;
7061 digi_volume = d;
7062 emusic_volume = e;
7063 zcmusic_bufsz = b;
7064 sfx_volume = s;
7065 pan_style = p;
7066 }
7067
7068 return D_O_K;
7069 }
7070
7071 int32_t queding(char const* s1, char const* s2, char const* s3)
7072 {
7073 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7074 }
7075
7076 int32_t onQuit()
7077 {
7078 if(Playing)
7079 {
7080 int32_t ret=0;
7081
7082 if(get_bit(quest_rules, qr_NOCONTINUE))
7083 {
7084 if(standalone_mode)
7085 {
7086 ret=queding("End current game?",
7087 "The continue screen is disabled; the game",
7088 "will be reloaded from the last save.");
7089 }
7090 else
7091 {
7092 ret=queding("End current game?",
7093 "The continue screen is disabled. You will",
7094 "be returned to the file select screen.");
7095 }
7096 }
7097 else
7098 ret=queding("End current game?",NULL,NULL);
7099
7100 if(ret==1)
7101 {
7102 disableClickToFreeze=false;
7103 Quit=qQUIT;
7104
7105 // Trying to evade a door repair charge?
7106 if(repaircharge)
7107 {
7108 game->change_drupy(-repaircharge);
7109 repaircharge=0;
7110 }
7111
7112 return D_CLOSE;
7113 }
7114 }
7115
7116 return D_O_K;
7117 }
7118
7119 int32_t onTryQuitMenu()
7120 {
7121 return onTryQuit(true);
7122 }
7123
7124 int32_t onTryQuit(bool inMenu)
7125 {
7126 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7127 {
7128 if(get_bit(quest_rules,qr_OLD_F6))
7129 {
7130 if(inMenu) onQuit();
7131 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7132 }
7133 else
7134 {
7135 disableClickToFreeze=false;
7136 GameFlags |= GAMEFLAG_TRYQUIT;
7137 }
7138 return D_CLOSE;
7139 }
7140
7141 return D_O_K;
7142 }
7143
7144 int32_t onReset()
7145 {
7146 if(queding(" Reset system? ",NULL,NULL)==1)
7147 {
7148 disableClickToFreeze=false;
7149 Quit=qRESET;
7150 replay_quit();
7151 return D_CLOSE;
7152 }
7153
7154 return D_O_K;
7155 }
7156
7157 int32_t onExit()
7158 {
7159 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7160 {
7161 Quit=qEXIT;
7162 return D_CLOSE;
7163 }
7164
7165 return D_O_K;
7166 }
7167
7168 int32_t onTitle_NES()
7169 {
7170 title_version=0;
7171 zc_set_config(cfg_sect,"title",title_version);
7172 return D_O_K;
7173 }
7174 int32_t onTitle_DX()
7175 {
7176 title_version=1;
7177 zc_set_config(cfg_sect,"title",title_version);
7178 return D_O_K;
7179 }
7180 int32_t onTitle_25()
7181 {
7182 title_version=2;
7183 zc_set_config(cfg_sect,"title",title_version);
7184 return D_O_K;
7185 }
7186
7187 int32_t onDebug()
7188 {
7189 if(debug_enabled)
7190 set_debug(!get_debug());
7191 return D_O_K;
7192 }
7193
7194 int32_t onHeartBeep()
7195 {
7196 heart_beep=!heart_beep;
7197 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7198 return D_O_K;
7199 }
7200
7201 int32_t onSaveIndicator()
7202 {
7203 use_save_indicator=!use_save_indicator;
7204 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7205 return D_O_K;
7206 }
7207
7208 int32_t onEpilepsy()
7209 {
7210 if(jwin_alert3(
7211 "Epilepsy Flash Reduction",
7212 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7213 "Disabling this will restore standard flash and wavy behaviour.",
7214 "Proceed?",
7215 "&Yes",
7216 "&No",
7217 NULL,
7218 'y',
7219 'n',
7220 0,
7221 lfont) == 1)
7222 {
7223 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7224 zc_set_config("zeldadx","checked_epilepsy",1);
7225 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7226 }
7227 return D_O_K;
7228 }
7229
7230 int32_t onTriforce()
7231 {
7232 for(int32_t i=0; i<MAXINITTABS; ++i)
7233 {
7234 init_tabs[i].flags&=~D_SELECTED;
7235 }
7236
7237 init_tabs[3].flags=D_SELECTED;
7238 return onCheatConsole();
7239 /*triforce_dlg[0].dp2=lfont;
7240 for(int32_t i=1; i<=8; i++)
7241 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7242
7243 if(zc_popup_dialog (triforce_dlg,-1)==9)
7244 {
7245 for(int32_t i=1; i<=8; i++)
7246 {
7247 game->lvlitems[i] &= ~liTRIFORCE;
7248 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7249 }
7250 }
7251 return D_O_K;*/
7252 }
7253
7254 bool rc = false;
7255 /*
7256 int32_t onEquipment()
7257 {
7258 for (int32_t i=0; i<MAXINITTABS; ++i)
7259 {
7260 init_tabs[i].flags&=~D_SELECTED;
7261 }
7262 init_tabs[0].flags=D_SELECTED;
7263 return onCheatConsole();
7264 }
7265 */
7266
7267 int32_t onItems()
7268 {
7269 for(int32_t i=0; i<MAXINITTABS; ++i)
7270 {
7271 init_tabs[i].flags&=~D_SELECTED;
7272 }
7273
7274 init_tabs[1].flags=D_SELECTED;
7275 return onCheatConsole();
7276 }
7277
7278 static DIALOG getnum_dlg[] =
7279 {
7280 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7281 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7282 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7283 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7284 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7285 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7286 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7287 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7288 };
7289
7290 int32_t getnumber(const char *prompt,int32_t initialval)
7291 {
7292 char buf[20];
7293 sprintf(buf,"%d",initialval);
7294 getnum_dlg[0].dp=(void *)prompt;
7295 getnum_dlg[0].dp2=lfont;
7296 getnum_dlg[2].dp=buf;
7297
7298 large_dialog(getnum_dlg);
7299
7300 if(zc_popup_dialog(getnum_dlg,2)==3)
7301 return atoi(buf);
7302
7303 return initialval;
7304 }
7305
7306 int32_t onLife()
7307 {
7308 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7309 cheats_enqueue(Cheat::Life, value);
7310 return D_O_K;
7311 }
7312
7313 int32_t onHeartC()
7314 {
7315 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7316 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7317 cheats_enqueue(Cheat::MaxLife, max_life);
7318 cheats_enqueue(Cheat::Life, life);
7319 return D_O_K;
7320 }
7321
7322 int32_t onMagicC()
7323 {
7324 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7325 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7326 cheats_enqueue(Cheat::MaxMagic, max_magic);
7327 cheats_enqueue(Cheat::Magic, magic);
7328 return D_O_K;
7329 }
7330
7331 int32_t onRupies()
7332 {
7333 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7334 cheats_enqueue(Cheat::Rupies, value);
7335 return D_O_K;
7336 }
7337
7338 int32_t onMaxBombs()
7339 {
7340 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7341 cheats_enqueue(Cheat::MaxBombs, value);
7342 cheats_enqueue(Cheat::Bombs, value);
7343 return D_O_K;
7344 }
7345
7346 int32_t onRefillLife()
7347 {
7348 cheats_enqueue(Cheat::Life, game->get_maxlife());
7349 return D_O_K;
7350 }
7351 int32_t onRefillMagic()
7352 {
7353 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7354 return D_O_K;
7355 }
7356 int32_t onClock()
7357 {
7358 cheats_enqueue(Cheat::Clock);
7359 return D_O_K;
7360 }
7361
7362 int32_t onQstPath()
7363 {
7364 char path[2048];
7365
7366 chop_path(qstdir);
7367 strcpy(path,qstdir);
7368
7369 go();
7370
7371 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7372 {
7373 chop_path(path);
7374 fix_filename_case(path);
7375 fix_filename_slashes(path);
7376 strcpy(qstdir,path);
7377 strcpy(qstpath,qstdir);
7378 }
7379
7380 comeback();
7381 return D_O_K;
7382 }
7383
7384 #include "dialog/cheat_dialog.h"
7385 int32_t onCheat()
7386 {
7387 call_setcheat_dialog();
7388 game->set_cheat(maxcheat);
7389 if(cheat) game->did_cheat(true);
7390 return D_O_K;
7391 }
7392
7393 int32_t onCheatRupies()
7394 {
7395 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7396 return D_O_K;
7397 }
7398
7399 int32_t onCheatArrows()
7400 {
7401 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7402 return D_O_K;
7403 }
7404
7405 int32_t onCheatBombs()
7406 {
7407 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7408 return D_O_K;
7409 }
7410
7411 // *** screen saver
7412
7413 3542 int32_t after_time()
7414 {
7415
1/2
✓ Branch 0 taken 3542 times.
✗ Branch 1 not taken.
3542 if(ss_enable == 0)
7416 return INT_MAX;
7417
7418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
3542 if(ss_after <= 0)
7419 return 5 * 60;
7420
7421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
3542 if(ss_after <= 3)
7422 return ss_after * 15 * 60;
7423
7424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
3542 if(ss_after <= 13)
7425 return (ss_after - 3) * 60 * 60;
7426
7427 3542 return MAX_IDLE + 1;
7428 3542 }
7429
7430 static const char *after_str[15] =
7431 {
7432 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7433 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7434 "Never"
7435 };
7436
7437 const char *after_list(int32_t index, int32_t *list_size)
7438 {
7439 if(index < 0)
7440 {
7441 *list_size = 15;
7442 return NULL;
7443 }
7444
7445 return after_str[index];
7446 }
7447
7448 29 static ListData after__list(after_list, &font);
7449
7450 static DIALOG scrsaver_dlg[] =
7451 {
7452 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7453 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7454 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7455 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7456 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7457 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7458 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7459 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7460 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7461 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7462 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7463 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7464 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7465 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7466 };
7467
7468 int32_t onScreenSaver()
7469 {
7470 scrsaver_dlg[0].dp2=lfont;
7471 int32_t oldcfgs[3];
7472 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7473 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7474 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7475
7476 large_dialog(scrsaver_dlg);
7477
7478 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7479
7480 if(ret == 8 || ret == 9)
7481 {
7482 ss_after = scrsaver_dlg[5].d1;
7483 ss_speed = scrsaver_dlg[6].d2;
7484 ss_density = scrsaver_dlg[7].d2;
7485 if(oldcfgs[0] != ss_after)
7486 zc_set_config(cfg_sect,"ss_after",ss_after);
7487 if(oldcfgs[1] != ss_speed)
7488 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7489 if(oldcfgs[2] != ss_density)
7490 zc_set_config(cfg_sect,"ss_density",ss_density);
7491 }
7492
7493 if(ret == 9)
7494 // preview Screen Saver
7495 {
7496 clear_keybuf();
7497 scare_mouse();
7498 Matrix(ss_speed, ss_density, 30);
7499 system_pal();
7500 unscare_mouse();
7501 }
7502
7503 return D_O_K;
7504 }
7505
7506 /***** Menus *****/
7507
7508 static MENU game_menu[] =
7509 {
7510 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7511 { (char *)"", NULL, NULL, 0, NULL },
7512 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7513 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7514 { (char *)"", NULL, NULL, 0, NULL },
7515 #ifdef __EMSCRIPTEN__
7516 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7517 #elif defined(ALLEGRO_MACOSX)
7518 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7519 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7520 #else
7521 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7522 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7523 #endif
7524 { NULL, NULL, NULL, 0, NULL }
7525 };
7526
7527 static MENU title_menu[] =
7528 {
7529 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7530 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7531 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7532 { NULL, NULL, NULL, 0, NULL }
7533 };
7534
7535 static MENU snapshot_format_menu[] =
7536 {
7537 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7538 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7539 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7540 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7541 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7542 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7543 { NULL, NULL, NULL, 0, NULL }
7544 };
7545
7546 static MENU controls_menu[] =
7547 {
7548 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7549 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7550 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7551 { NULL, NULL, NULL, 0, NULL }
7552 };
7553
7554 static MENU name_entry_mode_menu[] =
7555 {
7556 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7557 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7558 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7559 { NULL, NULL, NULL, 0, NULL }
7560 };
7561
7562 static void set_controls_menu_active()
7563 {
7564
7565 }
7566
7567 static MENU settings_menu[] =
7568 {
7569 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7570 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7571 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7572 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7573 { (char *)"", NULL, NULL, 0, NULL },
7574 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7575 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7576 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7577 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7578 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7579 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7580 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7581 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7582 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7583 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7584 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7585 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7586 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7587 { (char *)"", NULL, NULL, 0, NULL },
7588 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7589 { (char *)"", NULL, NULL, 0, NULL },
7590 { NULL, NULL, NULL, 0, NULL }
7591 };
7592
7593
7594 static MENU misc_menu[] =
7595 {
7596 { (char *)"&About...", onAbout, NULL, 0, NULL },
7597 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7598 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7599 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7600 { (char *)"", NULL, NULL, 0, NULL },
7601 //5
7602 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7603 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7604 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7605 { (char *)"", NULL, NULL, 0, NULL },
7606 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7607 //10
7608 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7609 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7610 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7611 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7612 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7613 //15
7614 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7615 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7616 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7617
7618 { NULL, NULL, NULL, 0, NULL }
7619 };
7620
7621 static MENU refill_menu[] =
7622 {
7623 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7624 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7625 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7626 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7627 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7628 { NULL, NULL, NULL, 0, NULL }
7629 };
7630
7631 static MENU show_menu[] =
7632 {
7633 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7634 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7635 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7636 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7637 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7638 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7639 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7640 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7641 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7642 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7643 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7644 { (char *)"", NULL, NULL, 0, NULL },
7645 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7646 { (char *)"", NULL, NULL, 0, NULL },
7647 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7648 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7649 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7650 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7651 { NULL, NULL, NULL, 0, NULL }
7652 };
7653
7654 static MENU cheat_menu[] =
7655 {
7656 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7657 { (char *)"", NULL, NULL, 0, NULL },
7658 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7659 { (char *)"", NULL, NULL, 0, NULL },
7660 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7661 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7662 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7663 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7664 { (char *)"", NULL, NULL, 0, NULL },
7665 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7666 { (char *)"", NULL, NULL, 0, NULL },
7667 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7668 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7669 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7670 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7671 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7672 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7673 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7674 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7675 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7676 { NULL, NULL, NULL, 0, NULL }
7677 };
7678
7679 static MENU fixes_menu[] =
7680 {
7681 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7682 { NULL, NULL, NULL, 0, NULL }
7683 };
7684
7685 #if DEVLEVEL > 0
7686 int32_t devLogging();
7687 int32_t devDebug();
7688 int32_t devTimestmp();
7689 #if DEVLEVEL > 1
7690 int32_t setCheat();
7691 #endif //DEVLEVEL > 1
7692 enum
7693 {
7694 dv_log,
7695 // dv_dbg,
7696 dv_tmpstmp,
7697 #if DEVLEVEL > 1
7698 dv_nil,
7699 dv_setcheat,
7700 #endif //DEVLEVEL > 1
7701 dv_max
7702 };
7703 static MENU dev_menu[] =
7704 {
7705 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7706 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7707 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7708 #if DEVLEVEL > 1
7709 { (char *)"", NULL, NULL, 0, NULL },
7710 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7711 #endif //DEVLEVEL > 1
7712 { NULL, NULL, NULL, 0, NULL }
7713 };
7714 int32_t devLogging()
7715 {
7716 dev_logging = !dev_logging;
7717 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7718 return D_O_K;
7719 }
7720 // int32_t devDebug()
7721 // {
7722 // dev_debug = !dev_debug;
7723 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7724 // return D_O_K;
7725 // }
7726 int32_t devTimestmp()
7727 {
7728 dev_timestmp = !dev_timestmp;
7729 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7730 return D_O_K;
7731 }
7732 #if DEVLEVEL > 1
7733 int32_t setCheat()
7734 {
7735 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7736 return D_O_K;
7737 }
7738 #endif //DEVLEVEL > 1
7739 #endif //DEVLEVEL > 0
7740
7741 MENU the_player_menu[] =
7742 {
7743 { (char *)"&Game", NULL, game_menu, 0, NULL },
7744 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7745 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7746 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7747 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7748 #if DEVLEVEL > 0
7749 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7750 #endif
7751 { NULL, NULL, NULL, 0, NULL }
7752 };
7753
7754 MENU the_player_menu2[] =
7755 {
7756 { (char *)"&Game", NULL, game_menu, 0, NULL },
7757 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7758 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7759 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7760 #if DEVLEVEL > 0
7761 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7762 #endif
7763 { NULL, NULL, NULL, 0, NULL }
7764 };
7765
7766 int32_t onMIDIPatch()
7767 {
7768 if(jwin_alert3(
7769 "Toggle Windows MIDI Fix",
7770 "This action will change whether ZC Player auto-restarts a MIDI at its",
7771 "last index if you move ZC Player out of focus, then back into focus.",
7772 "Proceed?",
7773 "&Yes",
7774 "&No",
7775 NULL,
7776 'y',
7777 'n',
7778 0,
7779 lfont) == 1)
7780 {
7781 midi_patch_fix = midi_patch_fix ? 0 : 1;
7782 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7783 }
7784 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
7785 return D_O_K;
7786 }
7787
7788 int32_t onKeyboardEntry()
7789 {
7790 NameEntryMode=0;
7791 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7792 return D_O_K;
7793 }
7794
7795 int32_t onLetterGridEntry()
7796 {
7797 NameEntryMode=1;
7798 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7799 return D_O_K;
7800 }
7801
7802 int32_t onExtLetterGridEntry()
7803 {
7804 NameEntryMode=2;
7805 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7806 return D_O_K;
7807 }
7808
7809 static BITMAP* oldscreen;
7810 int32_t onFullscreenMenu()
7811 {
7812 // super hacks
7813 screen = oldscreen;
7814 if (onFullscreen() == D_REDRAW)
7815 {
7816 oldscreen = screen;
7817 }
7818 screen = menu_bmp;
7819 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7820 return D_O_K;
7821 }
7822
7823 29 void fix_menu()
7824 {
7825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7826 29 settings_menu[18].text = NULL;
7827 29 }
7828
7829 static DIALOG system_dlg[] =
7830 {
7831 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7832 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7833 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7834 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7835 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7836 #ifndef ALLEGRO_MACOSX
7837 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7838 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7839 #else
7840 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7841 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7842 #endif
7843 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7844 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7845 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7846 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7847 };
7848
7849 static DIALOG system_dlg2[] =
7850 {
7851 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7852 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
7853 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7854 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7855 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7856 #ifndef ALLEGRO_MACOSX
7857 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7858 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7859 #else
7860 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7861 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7862 #endif
7863 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7864 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7865 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7866 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7867 };
7868
7869 void reset_snapshot_format_menu()
7870 {
7871 for(int32_t i=0; i<ssfmtMAX; ++i)
7872 {
7873 snapshot_format_menu[i].flags=0;
7874 }
7875 }
7876
7877 int32_t onSetSnapshotFormat()
7878 {
7879 switch(active_menu->text[1])
7880 {
7881 case 'B': //"&BMP"
7882 SnapshotFormat=0;
7883 break;
7884
7885 case 'G': //"&GIF"
7886 SnapshotFormat=1;
7887 break;
7888
7889 case 'J': //"&JPG"
7890 SnapshotFormat=2;
7891 break;
7892
7893 case 'P': //"&PNG"
7894 SnapshotFormat=3;
7895 break;
7896
7897 case 'C': //"PC&X"
7898 SnapshotFormat=4;
7899 break;
7900
7901 case 'T': //"&TGA"
7902 SnapshotFormat=5;
7903 break;
7904
7905 case 'L': //"&LBM"
7906 SnapshotFormat=6;
7907 break;
7908 }
7909 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7910
7911 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7912 return D_O_K;
7913 }
7914
7915
7916 29 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7917 {
7918 PALETTE tmp;
7919
7920
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<256; i++)
7921 {
7922 7424 tmp[i].r=r;
7923 7424 tmp[i].g=g;
7924 7424 tmp[i].b=b;
7925 7424 }
7926
7927 29 fade_interpolate(src,tmp,dest,pos,from,to);
7928 29 }
7929
7930 29 void system_pal()
7931 {
7932 29 is_sys_pal = true;
7933 static PALETTE pal;
7934 29 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7935
7936 // set up the grayscale palette
7937
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 29 times.
1885 for(int32_t i=128; i<192; i++)
7938 {
7939 1856 pal[i].r = i-128;
7940 1856 pal[i].g = i-128;
7941 1856 pal[i].b = i-128;
7942 1856 }
7943 29 load_colorset(gui_colorset, pal, jwin_a5_colors);
7944
7945 29 color_layer(pal, pal, 24,16,16, 28, 128,191);
7946
7947
2/2
✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 29 times.
3741 for(int32_t i=0; i<256; i+=2)
7948 {
7949 3712 int32_t v = (i>>3)+2;
7950 3712 int32_t c = (i>>3)+192;
7951 3712 pal[c] = _RGB(v,v,v+(v>>1));
7952 /*
7953 if(i<240)
7954 {
7955 _allegro_hline(tmp_scr,0,i,319,c);
7956 _allegro_hline(tmp_scr,0,i+1,319,c);
7957 }
7958 */
7959 3712 }
7960
7961 // draw the vertical screen gradient
7962
2/2
✓ Branch 0 taken 6960 times.
✓ Branch 1 taken 29 times.
6989 for(int32_t i=0; i<240; ++i)
7963 {
7964 6960 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7965 6960 }
7966
7967 /*
7968 palrstart= 10*63/255; palrend=166*63/255;
7969 palgstart= 36*63/255; palgend=202*63/255;
7970 palbstart=106*63/255; palbend=240*63/255;
7971 paldivs=32;
7972 for(int32_t i=0; i<paldivs; i++)
7973 {
7974 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7975 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7976 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7977 }
7978 */
7979 29 BITMAP *panorama = create_bitmap_ex(8,256,224);
7980 int32_t ts_height, ts_start;
7981
7982
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7983 {
7984 clear_to_color(panorama,0);
7985 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7986 ts_height=224-passive_subscreen_height;
7987 ts_start=28;
7988 }
7989 else
7990 {
7991 29 blit(framebuf,panorama,0,0,0,0,256,224);
7992 29 ts_height=224;
7993 29 ts_start=0;
7994 }
7995
7996 // gray scale the current frame
7997
2/2
✓ Branch 0 taken 6496 times.
✓ Branch 1 taken 29 times.
6525 for(int32_t y=0; y<ts_height; y++)
7998 {
7999
2/2
✓ Branch 0 taken 1662976 times.
✓ Branch 1 taken 6496 times.
1669472 for(int32_t x=0; x<256; x++)
8000 {
8001 1662976 int32_t c = panorama->line[y+ts_start][x];
8002
1/2
✓ Branch 0 taken 1662976 times.
✗ Branch 1 not taken.
1662976 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8003 1662976 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8004 1662976 }
8005 6496 }
8006
8007 29 destroy_bitmap(panorama);
8008
8009 // display everything
8010 29 vsync();
8011 29 hw_palette = &pal;
8012 29 update_hw_pal = true;
8013
8014 // sys_pal = pal;
8015 29 memcpy(sys_pal,pal,sizeof(pal));
8016 29 }
8017
8018 void system_pal2()
8019 {
8020 is_sys_pal = true;
8021 static PALETTE RAMpal2;
8022 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8023
8024 /* Windows 2000 colors
8025 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8026 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8027 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8028 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8029 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8030 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8031 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8032 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8033
8034 byte palrstart= 10*63/255, palrend=166*63/255,
8035 palgstart= 36*63/255, palgend=202*63/255,
8036 palbstart=106*63/255, palbend=240*63/255,
8037 paldivs=7;
8038 for(int32_t i=0; i<paldivs; i++)
8039 {
8040 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8041 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8042 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8043 }
8044 */
8045
8046 /* Windows 98 colors
8047 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8048 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8049 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8050 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8051 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8052 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8053 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8054 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8055
8056 byte palrstart= 0*63/255, palrend=166*63/255,
8057 palgstart= 0*63/255, palgend=202*63/255,
8058 palbstart=128*63/255, palbend=240*63/255,
8059 paldivs=7;
8060 for(int32_t i=0; i<paldivs; i++)
8061 {
8062 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8063 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8064 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8065 }
8066 */
8067
8068 /* Windows 99 colors
8069 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8070 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8071 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8072 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8073 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8074 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8075 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8076 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8077 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8078
8079 byte palrstart= 0*63/255, palrend=166*63/255,
8080 palgstart= 0*63/255, palgend=202*63/255,
8081
8082 palbstart=128*63/255, palbend=240*63/255,
8083 paldivs=6;
8084 for(int32_t i=0; i<paldivs; i++)
8085 {
8086 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8087 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8088 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8089 }
8090 */
8091
8092
8093
8094 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8095 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8096 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8097 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8098 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8099 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8100 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8101 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8102 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8103
8104 byte palrstart= 0*63/255, palrend=166*63/255,
8105 palgstart= 0*63/255, palgend=202*63/255,
8106 palbstart=128*63/255, palbend=240*63/255,
8107 paldivs=6;
8108
8109 for(int32_t i=0; i<paldivs; i++)
8110 {
8111 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8112 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8113 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8114 }
8115
8116 gui_bg_color=jwin_pal[jcBOX];
8117 gui_fg_color=jwin_pal[jcBOXFG];
8118
8119 jwin_set_colors(jwin_pal);
8120
8121
8122 // set up the new palette
8123 for(int32_t i=128; i<192; i++)
8124 {
8125 RAMpal2[i].r = i-128;
8126 RAMpal2[i].g = i-128;
8127 RAMpal2[i].b = i-128;
8128 }
8129
8130 /*
8131 for(int32_t i=0; i<64; i++)
8132 {
8133 RAMpal2[128+i] = _RGB(i,i,i)1));
8134 }
8135 */
8136
8137 /*
8138
8139 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8140 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8141 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8142 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8143 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8144 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8145 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8146
8147 gui_fg_color=vc(14);
8148 gui_bg_color=vc(1);
8149
8150 jwin_set_colors(jwin_pal);
8151 */
8152
8153 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8154
8155 // set up the colors for the vertical screen gradient
8156 for(int32_t i=0; i<256; i+=2)
8157 {
8158 int32_t v = (i>>3)+2;
8159 int32_t c = (i>>3)+192;
8160 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8161
8162 /*
8163 if(i<240)
8164 {
8165 _allegro_hline(tmp_scr,0,i,319,c);
8166 _allegro_hline(tmp_scr,0,i+1,319,c);
8167 }
8168 */
8169 }
8170
8171 // hw_palette = &RAMpal;
8172 // update_hw_pal = true;
8173
8174 for(int32_t i=0; i<240; ++i)
8175 {
8176 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8177 }
8178
8179 /*
8180 byte palrstart= 10*63/255, palrend=166*63/255,
8181 palgstart= 36*63/255, palgend=202*63/255,
8182 palbstart=106*63/255, palbend=240*63/255,
8183 paldivs=32;
8184 for(int32_t i=0; i<paldivs; i++)
8185 {
8186 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8187 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8188 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8189 }
8190 */
8191 BITMAP *panorama = create_bitmap_ex(8,256,224);
8192 int32_t ts_height, ts_start;
8193
8194 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8195 {
8196 clear_to_color(panorama,0);
8197 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8198 ts_height=224-passive_subscreen_height;
8199 ts_start=28;
8200 }
8201 else
8202 {
8203 blit(framebuf,panorama,0,0,0,0,256,224);
8204 ts_height=224;
8205 ts_start=0;
8206 }
8207
8208 // gray scale the current frame
8209 for(int32_t y=0; y<ts_height; y++)
8210 {
8211 for(int32_t x=0; x<256; x++)
8212 {
8213 int32_t c = panorama->line[y+ts_start][x];
8214 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8215 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8216 }
8217 }
8218
8219 destroy_bitmap(panorama);
8220
8221 // display everything
8222 vsync();
8223 hw_palette = &RAMpal2;
8224 update_hw_pal = true;
8225
8226 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8227
8228 // sys_pal = pal;
8229 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8230 }
8231
8232 static uint32_t entered_sys_pal = 0;
8233 void enter_sys_pal()
8234 {
8235 if(is_sys_pal)
8236 {
8237 if(entered_sys_pal)
8238 ++entered_sys_pal;
8239 return;
8240 }
8241 system_pal();
8242 ++entered_sys_pal;
8243 }
8244 void exit_sys_pal()
8245 {
8246 if(entered_sys_pal)
8247 {
8248 if(!--entered_sys_pal)
8249 {
8250 game_pal();
8251 }
8252 }
8253 }
8254
8255 void switch_out_callback()
8256 {
8257 if (pause_in_background)
8258 {
8259 callback_switchin = 3;
8260 return;
8261 }
8262
8263 #ifdef _WIN32
8264 if(midi_patch_fix==0 || currmidi==-1)
8265 return;
8266
8267
8268 paused_midi_pos = midi_pos;
8269 zc_stop_midi();
8270 midi_paused=true;
8271 midi_suspended = midissuspHALTED;
8272 #endif
8273 }
8274
8275 void switch_in_callback()
8276 {
8277 if(pause_in_background)
8278 {
8279 return;
8280 }
8281
8282 #ifdef _WIN32
8283 if(midi_patch_fix==0 || currmidi==-1)
8284 return;
8285
8286 else
8287 {
8288 callback_switchin = 1;
8289 midi_suspended = midissuspRESUME;
8290 }
8291 #endif
8292 }
8293
8294 57 void game_pal()
8295 {
8296 57 is_sys_pal = false;
8297 57 entered_sys_pal = 0;
8298 57 clear_to_color(screen,BLACK);
8299 57 hw_palette = &RAMpal;
8300 57 update_hw_pal = true;
8301 57 }
8302
8303 static char bar_str[] = "";
8304
8305 void music_pause()
8306 {
8307 //al_pause_duh(tmplayer);
8308 zcmusic_pause(zcmusic, ZCM_PAUSE);
8309 zc_midi_pause();
8310 midi_paused=true;
8311 }
8312
8313 void music_resume()
8314 {
8315 //al_resume_duh(tmplayer);
8316 zcmusic_pause(zcmusic, ZCM_RESUME);
8317 zc_midi_resume();
8318 midi_paused=false;
8319 }
8320
8321 52 void music_stop()
8322 {
8323 //al_stop_duh(tmplayer);
8324 //unload_duh(tmusic);
8325 //tmusic=NULL;
8326 //tmplayer=NULL;
8327 52 zcmusic_stop(zcmusic);
8328 52 zcmusic_unload_file(zcmusic);
8329 52 zc_stop_midi();
8330 52 midi_paused=false;
8331 52 currmidi=-1;
8332 52 }
8333
8334 void System()
8335 {
8336 mouse_down=gui_mouse_b();
8337 music_pause();
8338 pause_all_sfx();
8339 MenuOpen = true;
8340 system_pal();
8341 // FONT *oldfont=font;
8342 // font=tfont;
8343
8344 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8345 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8346
8347 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8348 #if DEVLEVEL > 1
8349 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8350 #endif
8351 game_menu[3].flags =
8352 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8353 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8354 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8355 clear_keybuf();
8356 show_mouse(screen);
8357
8358 DIALOG_PLAYER *p;
8359
8360 clear_bitmap(menu_bmp);
8361 oldscreen = screen;
8362 screen = menu_bmp;
8363
8364 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8365 {
8366 p = init_dialog(system_dlg2,-1);
8367 }
8368 else
8369 {
8370 p = init_dialog(system_dlg,-1);
8371 }
8372
8373 // drop the menu on startup if menu button pressed
8374 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8375 simulate_keypress(KEY_G << 8);
8376
8377 do
8378 {
8379 if(close_button_quit)
8380 {
8381 close_button_quit = false;
8382 f_Quit(qEXIT);
8383 if(Quit) break;
8384 }
8385 rest(17);
8386
8387 if(mouse_down && !gui_mouse_b())
8388 mouse_down=0;
8389
8390 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8391 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8392 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8393
8394 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8395 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8396 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8397 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8398 settings_menu[8].flags = NESquit?D_SELECTED:0;
8399 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8400 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8401 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8402 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8403 settings_menu[13].flags = volkeys?D_SELECTED:0;
8404 //Epilepsy Prevention
8405 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8406
8407 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8408 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8409 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8410
8411 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8412 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8413 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8414
8415 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8416 cheat_menu[0].flags = 0;
8417 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8418 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8419 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8420 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8421 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8422 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8423 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8424 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8425 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8426
8427 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8428 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8429 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8430 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8431 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8432 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8433 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8434 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8435 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8436 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8437 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8438 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8439 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8440 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8441 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8442
8443 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8444 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8445
8446 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8447 (char *)"Disable recording new saves" :
8448 (char *)"Enable recording new saves";
8449 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8450 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8451 (char *)"Stop recording" :
8452 (char *)"Stop replaying";
8453 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8454 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8455 (char *)"Disable snapshot all frames" :
8456 (char *)"Enable snapshot all frames";
8457
8458 reset_snapshot_format_menu();
8459 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8460
8461 if(debug_enabled)
8462 {
8463 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8464 }
8465
8466 if(gui_mouse_b() && !mouse_down)
8467 break;
8468
8469 // press menu to drop the menu
8470 if(rMbtn())
8471 simulate_keypress(KEY_G << 8);
8472
8473 if(input_idle(true) > after_time())
8474 // run Screeen Saver
8475 {
8476 // Screen saver enabled for now.
8477 clear_keybuf();
8478 scare_mouse();
8479 Matrix(ss_speed, ss_density, 0);
8480 system_pal();
8481 unscare_mouse();
8482 broadcast_dialog_message(MSG_DRAW, 0);
8483 }
8484
8485 update_hw_screen();
8486 }
8487 while(update_dialog(p));
8488
8489 screen = oldscreen;
8490
8491 // font=oldfont;
8492 mouse_down=gui_mouse_b();
8493 shutdown_dialog(p);
8494 show_mouse(NULL);
8495 MenuOpen = false;
8496 if(Quit)
8497 {
8498 kill_sfx();
8499 music_stop();
8500 update_hw_screen();
8501 }
8502 else
8503 {
8504 game_pal();
8505 music_resume();
8506 resume_all_sfx();
8507
8508 if(rc)
8509 ringcolor(false);
8510 }
8511
8512 eat_buttons();
8513
8514 rc=false;
8515 clear_keybuf();
8516 // text_mode(0);
8517 }
8518
8519 29 void fix_dialogs()
8520 {
8521 29 jwin_center_dialog(about_dlg);
8522 29 jwin_center_dialog(gamepad_dlg);
8523 29 jwin_center_dialog(credits_dlg);
8524 29 jwin_center_dialog(gamemode_dlg);
8525 29 jwin_center_dialog(getnum_dlg);
8526 29 jwin_center_dialog(goto_dlg);
8527 29 jwin_center_dialog(keyboard_control_dlg);
8528 29 jwin_center_dialog(midi_dlg);
8529 29 jwin_center_dialog(quest_dlg);
8530 29 jwin_center_dialog(scrsaver_dlg);
8531 29 jwin_center_dialog(sound_dlg);
8532 29 jwin_center_dialog(triforce_dlg);
8533
8534 // digi_dp[1] += scrx;
8535 // digi_dp[2] += scry;
8536 // midi_dp[1] += scrx;
8537 // midi_dp[2] += scry;
8538 // pan_dp[1] += scrx;
8539 // pan_dp[2] += scry;
8540 // emus_dp[1] += scrx;
8541 // emus_dp[2] += scry;
8542 // buf_dp[1] += scrx;
8543 // buf_dp[2] += scry;
8544 // sfx_dp[1] += scrx;
8545 // sfx_dp[2] += scry;
8546 29 }
8547
8548 /*****************************/
8549 /**** Custom Sound System ****/
8550 /*****************************/
8551
8552 67 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8553 {
8554
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8555 }
8556
8557 // Run an NSF, or a MIDI if the NSF is missing somehow.
8558 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8559 {
8560 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8561
8562 // Found it
8563 if(newzcmusic!=NULL)
8564 {
8565 zcmusic_stop(zcmusic);
8566 zcmusic_unload_file(zcmusic);
8567 zc_stop_midi();
8568
8569 zcmusic=newzcmusic;
8570 zcmusic_play(zcmusic, emusic_volume);
8571
8572 if(track>0)
8573 zcmusic_change_track(zcmusic,track);
8574
8575 return true;
8576 }
8577
8578 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8579 else if(midi>-1000)
8580 jukebox(midi);
8581
8582 return false;
8583 }
8584
8585 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8586 {
8587 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8588 // Found it
8589 if(newzcmusic!=NULL)
8590 {
8591 zcmusic_stop(zcmusic);
8592 zcmusic_unload_file(zcmusic);
8593 zc_stop_midi();
8594
8595 zcmusic=newzcmusic;
8596 zcmusic_play(zcmusic, emusic_volume);
8597
8598 if(track>0)
8599 zcmusic_change_track(zcmusic,track);
8600
8601 return true;
8602 }
8603
8604 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8605 else if(midi>-1000)
8606 jukebox(midi);
8607
8608 return false;
8609 }
8610
8611 int32_t get_zcmusicpos()
8612 {
8613 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8614 return debugtracething;
8615 return 0;
8616 }
8617
8618 void set_zcmusicpos(int32_t position)
8619 {
8620 zcmusic_set_curpos(zcmusic, position);
8621 }
8622
8623 void set_zcmusicspeed(int32_t speed)
8624 {
8625 int32_t newspeed = vbound(speed, 0, 10000);
8626 zcmusic_set_speed(zcmusic, newspeed);
8627 }
8628
8629 19 void jukebox(int32_t index,int32_t loop)
8630 {
8631 19 music_stop();
8632
8633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(index<0) index=MAXMIDIS-1;
8634
8635
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(index>=MAXMIDIS) index=0;
8636
8637 19 music_stop();
8638
8639 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8640 // stuck notes when a song stops. This fixes it.
8641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(strcmp(midi_driver->name, "DIGMID")==0)
8642 zc_set_volume(0, 0);
8643
8644 19 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8645 19 zc_play_midi((MIDI*)tunes[index].data,loop);
8646
8647
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(tunes[index].start>0)
8648 2 zc_midi_seek(tunes[index].start);
8649
8650 19 midi_loop_start = tunes[index].loop_start;
8651 19 midi_loop_end = tunes[index].loop_end;
8652
8653 19 currmidi=index;
8654 19 master_volume(digi_volume,midi_volume);
8655 19 midi_paused=false;
8656 19 }
8657
8658 19 void jukebox(int32_t index)
8659 {
8660
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(index<0) index=MAXMIDIS-1;
8661
8662
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(index>=MAXMIDIS) index=0;
8663
8664 // do nothing if it's already playing
8665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19 if(index==currmidi && midi_pos>=0)
8666 {
8667 midi_paused=false;
8668 return;
8669 }
8670
8671 19 jukebox(index,tunes[index].loop);
8672 19 }
8673
8674 29 void play_DmapMusic()
8675 {
8676 static char tfile[2048];
8677 static int32_t ttrack=0;
8678 29 bool domidi=false;
8679
8680
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 21 times.
29 if(DMaps[currdmap].tmusic[0]!=0)
8681 {
8682
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(zcmusic==NULL ||
8683 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8684 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8685 {
8686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(zcmusic != NULL)
8687 {
8688 zcmusic_stop(zcmusic);
8689 zcmusic_unload_file(zcmusic);
8690 zcmusic = NULL;
8691 }
8692
8693 8 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8694
8695
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 if(zcmusic!=NULL)
8696 {
8697 5 zc_stop_midi();
8698 5 strcpy(tfile,DMaps[currdmap].tmusic);
8699 5 zcmusic_play(zcmusic, emusic_volume);
8700 5 int32_t temptracks=0;
8701 5 temptracks=zcmusic_get_tracks(zcmusic);
8702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 temptracks=(temptracks<2)?1:temptracks;
8703 5 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8704 5 zcmusic_change_track(zcmusic,ttrack);
8705 5 }
8706 else
8707 {
8708 3 tfile[0] = 0;
8709 3 domidi=true;
8710 }
8711 8 }
8712 8 }
8713 else
8714 {
8715 21 domidi=true;
8716 }
8717
8718
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 24 times.
29 if(domidi)
8719 {
8720 24 int32_t m=DMaps[currdmap].midi;
8721
8722
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
24 switch(m)
8723 {
8724 case 1:
8725 12 jukebox(ZC_MIDI_OVERWORLD);
8726 12 break;
8727
8728 case 2:
8729 1 jukebox(ZC_MIDI_DUNGEON);
8730 1 break;
8731
8732 case 3:
8733 jukebox(ZC_MIDI_LEVEL9);
8734 break;
8735
8736 default:
8737
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
11 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8738 6 jukebox(m+MIDIOFFSET_DMAP);
8739 else
8740 5 music_stop();
8741 11 }
8742 24 }
8743 29 }
8744
8745 29 void playLevelMusic()
8746 {
8747 29 int32_t m=tmpscr->screen_midi;
8748
8749
1/6
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 switch(m)
8750 {
8751 case -2:
8752 music_stop();
8753 break;
8754
8755 case -1:
8756 29 play_DmapMusic();
8757 29 break;
8758
8759 case 1:
8760 jukebox(ZC_MIDI_OVERWORLD);
8761 break;
8762
8763 case 2:
8764 jukebox(ZC_MIDI_DUNGEON);
8765 break;
8766
8767 case 3:
8768 jukebox(ZC_MIDI_LEVEL9);
8769 break;
8770
8771 default:
8772 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8773 jukebox(m+MIDIOFFSET_MAPSCR);
8774 else
8775 music_stop();
8776 }
8777 29 }
8778
8779 48 void master_volume(int32_t dv,int32_t mv)
8780 {
8781
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
48 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8782
8783
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
48 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8784
8785
5/6
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 30 times.
48 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8786 48 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8787 48 }
8788
8789 /*****************/
8790 /***** SFX *****/
8791 /*****************/
8792
8793 // array of voices, one for each sfx sample in the data file
8794 // 0+ = voice #
8795 // -1 = voice not allocated
8796 29 void Z_init_sound()
8797 {
8798
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8799 7424 sfx_voice[i]=-1;
8800
8801
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8802 203 tunes[i].data = (MIDI*)mididata[i].dat;
8803
8804
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8805 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8806
8807 29 master_volume(digi_volume,midi_volume);
8808 29 }
8809
8810 // returns number of voices currently allocated
8811 int32_t sfx_count()
8812 {
8813 int32_t c=0;
8814
8815 for(int32_t i=0; i<WAV_COUNT; i++)
8816 if(sfx_voice[i]!=-1)
8817 ++c;
8818
8819 return c;
8820 }
8821
8822 // clean up finished samples
8823 3514 void sfx_cleanup()
8824 {
8825
2/2
✓ Branch 0 taken 899584 times.
✓ Branch 1 taken 3514 times.
903098 for(int32_t i=0; i<WAV_COUNT; i++)
8826
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 899556 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
899612 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8827 {
8828 28 deallocate_voice(sfx_voice[i]);
8829 28 sfx_voice[i]=-1;
8830 28 }
8831 3514 }
8832
8833 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8834 // if a voice is already allocated (and/or playing), then it just returns true
8835 // Returns true: voice is allocated
8836 // false: unsuccessful
8837 86 bool sfx_init(int32_t index)
8838 {
8839 // check index
8840
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
86 if(index<=0 || index>=WAV_COUNT)
8841 58 return false;
8842
8843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(sfx_voice[index]==-1)
8844 {
8845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(sfxdat)
8846 {
8847 if(index<Z35)
8848 {
8849 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8850 }
8851 else
8852 {
8853 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8854 }
8855 }
8856 else
8857 {
8858 28 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8859 }
8860
8861 28 voice_set_volume(sfx_voice[index], sfx_volume);
8862 28 }
8863
8864 28 return sfx_voice[index] != -1;
8865 86 }
8866
8867 // plays an sfx sample
8868 34 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8869 {
8870
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 6 times.
34 if(!sfx_init(index))
8871 6 return;
8872
8873 28 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8874 28 voice_set_pan(sfx_voice[index],pan);
8875
8876 28 int32_t pos = voice_get_position(sfx_voice[index]);
8877
8878
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(restart) voice_set_position(sfx_voice[index],0);
8879
8880
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(pos<=0)
8881 28 voice_start(sfx_voice[index]);
8882 34 }
8883
8884 // true if sfx is allocated
8885 5 bool sfx_allocated(int32_t index)
8886 {
8887
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8888 }
8889
8890 // start it (in loop mode) if it's not already playing,
8891 // otherwise adjust it to play in loop mode -DD
8892 52 void cont_sfx(int32_t index)
8893 {
8894
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(!sfx_init(index))
8895 {
8896 52 return;
8897 }
8898
8899 if(voice_get_position(sfx_voice[index])<=0)
8900 {
8901 voice_set_position(sfx_voice[index],0);
8902 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8903 voice_start(sfx_voice[index]);
8904 }
8905 else
8906 {
8907 adjust_sfx(index, 128, true);
8908 }
8909 52 }
8910
8911 // adjust parameters while playing
8912 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8913 {
8914 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8915 return;
8916
8917 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8918 voice_set_pan(sfx_voice[index],pan);
8919 }
8920
8921 // pauses a voice
8922 void pause_sfx(int32_t index)
8923 {
8924 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8925 voice_stop(sfx_voice[index]);
8926 }
8927
8928 // resumes a voice
8929 void resume_sfx(int32_t index)
8930 {
8931 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8932 voice_start(sfx_voice[index]);
8933 }
8934
8935 // pauses all active voices
8936 1 void pause_all_sfx()
8937 {
8938
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
8939
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(sfx_voice[i]!=-1)
8940 voice_stop(sfx_voice[i]);
8941 1 }
8942
8943 // resumes all paused voices
8944 void resume_all_sfx()
8945 {
8946 for(int32_t i=0; i<WAV_COUNT; i++)
8947 if(sfx_voice[i]!=-1)
8948 voice_start(sfx_voice[i]);
8949 }
8950
8951 // stops an sfx and deallocates the voice
8952 1216 void stop_sfx(int32_t index)
8953 {
8954
3/4
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1182 times.
✗ Branch 3 not taken.
1216 if(index<=0 || index>=WAV_COUNT)
8955 34 return;
8956
8957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1182 times.
1182 if(sfx_voice[index]!=-1)
8958 {
8959 deallocate_voice(sfx_voice[index]);
8960 sfx_voice[index]=-1;
8961 }
8962 1216 }
8963
8964 // Stops SFX played by Hero's item of the given family
8965 3 void stop_item_sfx(int32_t family)
8966 {
8967 3 int32_t id=current_item_id(family);
8968
8969
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(id<0)
8970 3 return;
8971
8972 stop_sfx(itemsbuf[id].usesound);
8973 3 }
8974
8975 7 void kill_sfx()
8976 {
8977
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7 times.
1799 for(int32_t i=0; i<WAV_COUNT; i++)
8978
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(sfx_voice[i]!=-1)
8979 {
8980 deallocate_voice(sfx_voice[i]);
8981 sfx_voice[i]=-1;
8982 }
8983 7 }
8984
8985 3 int32_t pan(int32_t x)
8986 {
8987
1/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 switch(pan_style)
8988 {
8989 case 0:
8990 return 128;
8991
8992 case 1:
8993 3 return vbound((x>>1)+68,0,255);
8994
8995 case 2:
8996 return vbound(((x*3)>>2)+36,0,255);
8997 }
8998
8999 return vbound(x,0,255);
9000 3 }
9001
9002 /*******************************/
9003 /******* Input Handlers ********/
9004 /*******************************/
9005
9006 24555 bool joybtn(int32_t b)
9007 {
9008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24555 times.
24555 if(b == 0)
9009 return false;
9010
9011 24555 return joy[joystick_index].button[b-1].b !=0;
9012 24555 }
9013
9014 const char* joybtn_name(int32_t b)
9015 {
9016 if(b == 0)
9017 return "";
9018
9019 return joy[joystick_index].button[b-1].name;
9020 }
9021
9022 int32_t next_press_key();
9023
9024 int32_t next_press_btn()
9025 {
9026 clear_keybuf();
9027 /*bool b[joy[joystick_index].num_buttons+1];
9028
9029 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9030 b[i]=joybtn(i);*/
9031
9032 //first, we need to wait until they're pressing no buttons
9033 for(;;)
9034 {
9035 if(keypressed())
9036 {
9037 switch(readkey()>>8)
9038 {
9039 case KEY_ESC:
9040 return -1;
9041
9042 case KEY_SPACE:
9043 return 0;
9044 }
9045 }
9046
9047 poll_joystick();
9048 bool done = true;
9049
9050 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9051 {
9052 if(joybtn(i)) done = false;
9053 }
9054
9055 if(done) break;
9056 rest(1);
9057 }
9058
9059 //now, we need to wait for them to press any button
9060 for(;;)
9061 {
9062 if(keypressed())
9063 {
9064 switch(readkey()>>8)
9065 {
9066 case KEY_ESC:
9067 return -1;
9068
9069 case KEY_SPACE:
9070 return 0;
9071 }
9072 }
9073
9074 poll_joystick();
9075
9076 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9077 {
9078 if(joybtn(i)) return i;
9079 }
9080 rest(1);
9081 }
9082 }
9083
9084 33336 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9085 {
9086
2/2
✓ Branch 0 taken 32338 times.
✓ Branch 1 taken 998 times.
33336 bool ret = btn && !flag;
9087
2/2
✓ Branch 0 taken 28950 times.
✓ Branch 1 taken 4386 times.
33336 flag = rawbtn ? *rawbtn : btn;
9088
9089 33336 return ret;
9090 }
9091 105 static bool rButtonPeek(bool btn, bool flag)
9092 {
9093
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!btn)
9094 {
9095 105 return false;
9096 }
9097 else if(!flag)
9098 {
9099 return true;
9100 }
9101
9102 return false;
9103 105 }
9104
9105 // Updated only by keyboard/gamepad.
9106 // If in replay mode, this is set directly by the replay system.
9107 // This should never be read from directly - use control_state instead.
9108 bool raw_control_state[ZC_CONTROL_STATES];
9109
9110 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9111 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9112 // lasts until the next call to load_control_state.
9113 bool control_state[ZC_CONTROL_STATES];
9114 bool disable_control[ZC_CONTROL_STATES];
9115 bool drunk_toggle_state[11];
9116 bool disabledKeys[127];
9117 bool KeyInput[127];
9118 bool KeyPress[127];
9119
9120 bool key_current_frame[127];
9121 bool key_previous_frame[127];
9122
9123 static bool key_system[127];
9124 static bool key_system_previous[127];
9125 static bool key_system_press[127];
9126
9127 bool button_press[ZC_CONTROL_STATES];
9128 bool button_hold[ZC_CONTROL_STATES];
9129
9130 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9131 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9132 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9133 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9134 #define STICK_PRECISION 56 //define your own sensitivity
9135
9136 1268 void load_control_state()
9137 {
9138 1268 load_control_called_this_frame = true;
9139
9140
3/4
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
1268 if (replay_get_version() >= 8 && replay_get_version() < 11)
9141 {
9142
2/2
✓ Branch 0 taken 9000 times.
✓ Branch 1 taken 500 times.
9500 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9143 9000 down_control_states[i] = raw_control_state[i];
9144 500 }
9145
9146
1/2
✓ Branch 0 taken 1268 times.
✗ Branch 1 not taken.
1268 if (!replay_is_replaying())
9147 {
9148 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9149 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9150 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9151 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9152 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9153 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9154 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9155 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9156 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9157 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9158 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9159 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9160 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9161 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9162
9163 if(num_joysticks != 0)
9164 {
9165 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9166 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9167 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9168 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9169 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9170 }
9171 else
9172 {
9173 raw_control_state[14] = false;
9174 raw_control_state[15] = false;
9175 raw_control_state[16] = false;
9176 raw_control_state[17] = false;
9177 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9178 }
9179 }
9180
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1262 times.
1268 if (replay_is_active())
9181 {
9182
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 661 times.
1262 if (replay_get_version() < 3)
9183 601 replay_poll();
9184
3/4
✓ Branch 0 taken 661 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 105 times.
661 else if (replay_is_replaying() && replay_get_version() < 6)
9185 105 replay_peek_input();
9186
4/6
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 500 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 500 times.
556 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9187 500 replay_peek_input();
9188
2/2
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 432 times.
1262 if (replay_get_version() == 8)
9189 432 update_keys();
9190 1262 }
9191
9192 // Some test replay files were made before a serious input bug was fixed, so instead
9193 // of re-doing them or tossing them out, just check for that zplay version.
9194
3/4
✓ Branch 0 taken 1256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 1156 times.
1268 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9195
2/2
✓ Branch 0 taken 22608 times.
✓ Branch 1 taken 1256 times.
23864 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9196 {
9197 22608 control_state[i] = raw_control_state[i];
9198
4/4
✓ Branch 0 taken 11808 times.
✓ Branch 1 taken 10800 times.
✓ Branch 2 taken 547 times.
✓ Branch 3 taken 11261 times.
22608 if (botched_input && !control_state[i])
9199 11261 down_control_states[i] = false;
9200 22608 }
9201
9202 1256 button_press[0]=rButton(control_state[0],button_hold[0]);
9203 1256 button_press[1]=rButton(control_state[1],button_hold[1]);
9204 1256 button_press[2]=rButton(control_state[2],button_hold[2]);
9205 1256 button_press[3]=rButton(control_state[3],button_hold[3]);
9206 1256 button_press[4]=rButton(control_state[4],button_hold[4]);
9207 1256 button_press[5]=rButton(control_state[5],button_hold[5]);
9208 1256 button_press[6]=rButton(control_state[6],button_hold[6]);
9209 1256 button_press[7]=rButton(control_state[7],button_hold[7]);
9210 1256 button_press[8]=rButton(control_state[8],button_hold[8]);
9211 1256 button_press[9]=rButton(control_state[9],button_hold[9]);
9212 1256 button_press[10]=rButton(control_state[10],button_hold[10]);
9213 1256 button_press[11]=rButton(control_state[11],button_hold[11]);
9214 1256 button_press[12]=rButton(control_state[12],button_hold[12]);
9215 1256 button_press[13]=rButton(control_state[13],button_hold[13]);
9216 1256 button_press[14]=rButton(control_state[14],button_hold[14]);
9217 1256 button_press[15]=rButton(control_state[15],button_hold[15]);
9218 1256 button_press[16]=rButton(control_state[16],button_hold[16]);
9219 1256 button_press[17]=rButton(control_state[17],button_hold[17]);
9220 1256 }
9221
9222 // Returns true if any game key is pressed. This is needed because keypressed()
9223 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9224 23352 bool zc_key_pressed()
9225 //may also need to use zc_getrawkey
9226 {
9227
7/10
✓ Branch 0 taken 20419 times.
✓ Branch 1 taken 2933 times.
✓ Branch 2 taken 2933 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2933 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2834 times.
✓ Branch 7 taken 2834 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2441 times.
25793 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9228
4/6
✓ Branch 0 taken 2834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2834 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2640 times.
✓ Branch 5 taken 2640 times.
2834 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9229
4/6
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2570 times.
✓ Branch 5 taken 2570 times.
2640 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9230
4/6
✓ Branch 0 taken 2570 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2470 times.
✓ Branch 5 taken 2470 times.
2570 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9231
1/2
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
2470 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9232
2/4
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2470 times.
✗ Branch 3 not taken.
2470 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9233
2/4
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2470 times.
✗ Branch 3 not taken.
2470 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9234
2/4
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2470 times.
✗ Branch 3 not taken.
2470 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9235
2/4
✓ Branch 0 taken 2470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2470 times.
✗ Branch 3 not taken.
2470 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9236
3/4
✓ Branch 0 taken 2441 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 2441 times.
✗ Branch 3 not taken.
2470 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9237
2/4
✓ Branch 0 taken 2441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441 times.
✗ Branch 3 not taken.
2441 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9238
2/4
✓ Branch 0 taken 2441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441 times.
✗ Branch 3 not taken.
2441 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9239
2/4
✓ Branch 0 taken 2441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2441 times.
✗ Branch 3 not taken.
2441 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9240
1/2
✓ Branch 0 taken 2441 times.
✗ Branch 1 not taken.
2441 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9241 41939 return true;
9242
9243 2441 return false;
9244 3542 }
9245
9246 24652 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9247 {
9248 24652 bool ret = false, drunkstate = false, rawret = false;
9249 24652 bool* flag = &down_control_states[btn];
9250
2/7
✓ Branch 0 taken 21102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3550 times.
24652 switch(btn)
9251 {
9252 case btnF12:
9253 ret = zc_getkey(KEY_F12, ignoreDisable);
9254 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9255 eatEntirely = false;
9256 break;
9257 case btnF11:
9258 ret = zc_getkey(KEY_F11, ignoreDisable);
9259 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9260 eatEntirely = false;
9261 break;
9262 case btnF5:
9263 ret = zc_getkey(KEY_F5, ignoreDisable);
9264 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9265 eatEntirely = false;
9266 break;
9267 case btnQ:
9268 ret = zc_getkey(KEY_Q, ignoreDisable);
9269 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9270 eatEntirely = false;
9271 break;
9272 case btnI:
9273 ret = zc_getkey(KEY_I, ignoreDisable);
9274 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9275 eatEntirely = false;
9276 break;
9277 case btnM:
9278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3550 times.
3550 if(FFCore.kb_typing_mode) return false;
9279 3550 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9280 3550 eatEntirely = false;
9281 3550 break;
9282 default: //control_state[] index
9283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21102 times.
21102 if(FFCore.kb_typing_mode) return false;
9284
5/6
✓ Branch 0 taken 20994 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 7360 times.
✓ Branch 3 taken 13634 times.
✓ Branch 4 taken 7360 times.
✗ Branch 5 not taken.
21102 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9285
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 19762 times.
21102 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9286
3/4
✓ Branch 0 taken 19206 times.
✓ Branch 1 taken 1896 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1896 times.
22998 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9287 21102 rawret = raw_control_state[btn];
9288 21102 }
9289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24652 times.
24652 assert(flag);
9290
2/2
✓ Branch 0 taken 13819 times.
✓ Branch 1 taken 10833 times.
24652 if(press)
9291 {
9292
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 10728 times.
10833 if(peek)
9293 105 ret = rButtonPeek(ret, *flag);
9294
3/4
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4386 times.
✓ Branch 3 taken 6342 times.
10728 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9295 4386 else ret = rButton(ret, *flag, &rawret);
9296 10833 }
9297
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24652 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24652 if(eatEntirely && ret) control_state[btn] = false;
9298
3/4
✓ Branch 0 taken 16688 times.
✓ Branch 1 taken 7964 times.
✓ Branch 2 taken 16688 times.
✗ Branch 3 not taken.
24652 if(drunk && drunkstate) ret = !ret;
9299 24652 return ret;
9300 24652 }
9301
9302 245 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9303 {
9304 245 byte ret = 0;
9305
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 105 times.
245 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9306
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9307
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9308
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9309
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9310
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9311
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9312
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9313 245 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9314 }
9315
9316 byte checkIntBtnVal(byte intbtn, byte vals)
9317 {
9318 return intbtn&vals;
9319 }
9320
9321 147 bool Up()
9322 {
9323 147 return getInput(btnUp);
9324 }
9325 57 bool Down()
9326 {
9327 57 return getInput(btnDown);
9328 }
9329 78 bool Left()
9330 {
9331 78 return getInput(btnLeft);
9332 }
9333 94 bool Right()
9334 {
9335 94 return getInput(btnRight);
9336 }
9337 135 bool cAbtn()
9338 {
9339 135 return getInput(btnA);
9340 }
9341 162 bool cBbtn()
9342 {
9343 162 return getInput(btnB);
9344 }
9345 bool cSbtn()
9346 {
9347 return getInput(btnS);
9348 }
9349 29 bool cLbtn()
9350 {
9351 29 return getInput(btnL);
9352 }
9353 29 bool cRbtn()
9354 {
9355 29 return getInput(btnR);
9356 }
9357 bool cPbtn()
9358 {
9359 return getInput(btnP);
9360 }
9361 bool cEx1btn()
9362 {
9363 return getInput(btnEx1);
9364 }
9365 bool cEx2btn()
9366 {
9367 return getInput(btnEx2);
9368 }
9369 bool cEx3btn()
9370 {
9371 return getInput(btnEx3);
9372 }
9373 bool cEx4btn()
9374 {
9375 return getInput(btnEx4);
9376 }
9377 bool AxisUp()
9378 {
9379 return getInput(btnAxisUp);
9380 }
9381 bool AxisDown()
9382 {
9383 return getInput(btnAxisDown);
9384 }
9385 bool AxisLeft()
9386 {
9387 return getInput(btnAxisLeft);
9388 }
9389 bool AxisRight()
9390 {
9391 return getInput(btnAxisRight);
9392 }
9393
9394 bool cMbtn()
9395 {
9396 return getInput(btnM);
9397 }
9398 bool cF12()
9399 {
9400 return getInput(btnF12);
9401 }
9402 bool cF11()
9403 {
9404 return getInput(btnF11);
9405 }
9406 bool cF5()
9407 {
9408 return getInput(btnF5);
9409 }
9410 bool cQ()
9411 {
9412 return getInput(btnQ);
9413 }
9414 bool cI()
9415 {
9416 return getInput(btnI);
9417 }
9418
9419 bool rUp()
9420 {
9421 return getInput(btnUp, true);
9422 }
9423 bool rDown()
9424 {
9425 return getInput(btnDown, true);
9426 }
9427 bool rLeft()
9428 {
9429 return getInput(btnLeft, true);
9430 }
9431 bool rRight()
9432 {
9433 return getInput(btnRight, true);
9434 }
9435 bool rAbtn()
9436 {
9437 return getInput(btnA, true);
9438 }
9439 bool rBbtn()
9440 {
9441 return getInput(btnB, true);
9442 }
9443 1178 bool rSbtn()
9444 {
9445 1178 return getInput(btnS, true);
9446 }
9447 3542 bool rMbtn()
9448 {
9449 3542 return getInput(btnM, true);
9450 }
9451 bool rLbtn()
9452 {
9453 return getInput(btnL, true);
9454 }
9455 bool rRbtn()
9456 {
9457 return getInput(btnR, true);
9458 }
9459 1208 bool rPbtn()
9460 {
9461 1208 return getInput(btnP, true);
9462 }
9463 bool rEx1btn()
9464 {
9465 return getInput(btnEx1, true);
9466 }
9467 bool rEx2btn()
9468 {
9469 return getInput(btnEx2, true);
9470 }
9471 52 bool rEx3btn()
9472 {
9473 52 return getInput(btnEx3, true);
9474 }
9475 52 bool rEx4btn()
9476 {
9477 52 return getInput(btnEx4, true);
9478 }
9479 bool rAxisUp()
9480 {
9481 return getInput(btnAxisUp, true);
9482 }
9483 bool rAxisDown()
9484 {
9485 return getInput(btnAxisDown, true);
9486 }
9487 bool rAxisLeft()
9488 {
9489 return getInput(btnAxisLeft, true);
9490 }
9491 bool rAxisRight()
9492 {
9493 return getInput(btnAxisRight, true);
9494 }
9495
9496 bool rF11()
9497 {
9498 return getInput(btnF11, true);
9499 }
9500 bool rQ()
9501 {
9502 return getInput(btnQ, true);
9503 }
9504 bool rI()
9505 {
9506 return getInput(btnI, true);
9507 }
9508
9509 2782 bool DrunkUp()
9510 {
9511 2782 return getInput(btnUp, false, true);
9512 }
9513 2425 bool DrunkDown()
9514 {
9515 2425 return getInput(btnDown, false, true);
9516 }
9517 1155 bool DrunkLeft()
9518 {
9519 1155 return getInput(btnLeft, false, true);
9520 }
9521 894 bool DrunkRight()
9522 {
9523 894 return getInput(btnRight, false, true);
9524 }
9525 1178 bool DrunkcAbtn()
9526 {
9527 1178 return getInput(btnA, false, true);
9528 }
9529 1213 bool DrunkcBbtn()
9530 {
9531 1213 return getInput(btnB, false, true);
9532 }
9533 1178 bool DrunkcEx1btn()
9534 {
9535 1178 return getInput(btnEx1, false, true);
9536 }
9537 1178 bool DrunkcEx2btn()
9538 {
9539 1178 return getInput(btnEx2, false, true);
9540 }
9541 bool DrunkcSbtn()
9542 {
9543 return getInput(btnS, false, true);
9544 }
9545 bool DrunkcMbtn()
9546 {
9547 return getInput(btnM, false, true);
9548 }
9549 bool DrunkcLbtn()
9550 {
9551 return getInput(btnL, false, true);
9552 }
9553 bool DrunkcRbtn()
9554 {
9555 return getInput(btnR, false, true);
9556 }
9557 bool DrunkcPbtn()
9558 {
9559 return getInput(btnP, false, true);
9560 }
9561
9562 bool DrunkrUp()
9563 {
9564 return getInput(btnUp, true, true);
9565 }
9566 bool DrunkrDown()
9567 {
9568 return getInput(btnDown, true, true);
9569 }
9570 bool DrunkrLeft()
9571 {
9572 return getInput(btnLeft, true, true);
9573 }
9574 bool DrunkrRight()
9575 {
9576 return getInput(btnRight, true, true);
9577 }
9578 1159 bool DrunkrAbtn()
9579 {
9580 1159 return getInput(btnA, true, true);
9581 }
9582 1159 bool DrunkrBbtn()
9583 {
9584 1159 return getInput(btnB, true, true);
9585 }
9586 34 bool DrunkrEx1btn()
9587 {
9588 34 return getInput(btnEx1, true, true);
9589 }
9590 34 bool DrunkrEx2btn()
9591 {
9592 34 return getInput(btnEx2, true, true);
9593 }
9594 bool DrunkrEx3btn()
9595 {
9596 return getInput(btnEx3, true, true);
9597 }
9598 bool DrunkrEx4btn()
9599 {
9600 return getInput(btnEx4, true, true);
9601 }
9602 bool DrunkrSbtn()
9603 {
9604 return getInput(btnS, true, true);
9605 }
9606 bool DrunkrMbtn()
9607 {
9608 return getInput(btnM, true, true);
9609 }
9610 1097 bool DrunkrLbtn()
9611 {
9612 1097 return getInput(btnL, true, true);
9613 }
9614 1097 bool DrunkrRbtn()
9615 {
9616 1097 return getInput(btnR, true, true);
9617 }
9618 bool DrunkrPbtn()
9619 {
9620 return getInput(btnP, true, true);
9621 }
9622
9623 8 void eat_buttons()
9624 {
9625 8 getInput(btnA, true, false, true);
9626 8 getInput(btnB, true, false, true);
9627 8 getInput(btnS, true, false, true);
9628 8 getInput(btnM, true, false, true);
9629 8 getInput(btnL, true, false, true);
9630 8 getInput(btnR, true, false, true);
9631 8 getInput(btnP, true, false, true);
9632 8 getInput(btnEx1, true, false, true);
9633 8 getInput(btnEx2, true, false, true);
9634 8 getInput(btnEx3, true, false, true);
9635 8 getInput(btnEx4, true, false, true);
9636 8 }
9637
9638 // Is true for the _first frame_ of a key press.
9639 // But! it is possible that a script manually sets the value of KeyPress,
9640 // in which case it will be restored to the "true" value based on `key_current_frame`
9641 // and `key_previous_frame` on the next frame.
9642 bool zc_readkey(int32_t k, bool ignoreDisable)
9643 {
9644 if(ignoreDisable) return KeyPress[k];
9645 switch(k)
9646 {
9647 case KEY_F7:
9648 case KEY_F8:
9649 case KEY_F9:
9650 return KeyPress[k];
9651
9652 default:
9653 return KeyPress[k] && !disabledKeys[k];
9654 }
9655 }
9656
9657 // Is true for _every frame_ a key is held down.
9658 // But! it is possible that a script manually sets the value of KeyInput,
9659 // in which case it will be restored to the "true" value based on `key_current_frame`
9660 // on the next frame.
9661 bool zc_getkey(int32_t k, bool ignoreDisable)
9662 {
9663 if(ignoreDisable) return KeyInput[k];
9664 switch(k)
9665 {
9666 case KEY_F7:
9667 case KEY_F8:
9668 case KEY_F9:
9669 return KeyInput[k];
9670
9671 default:
9672 return KeyInput[k] && !disabledKeys[k];
9673 }
9674 }
9675
9676 // Reads (and then clears) the current frame key state directly.
9677 // Scripts can also modify `key_current_frame`.
9678 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9679 {
9680 if(zc_getrawkey(k, ignoreDisable))
9681 {
9682 _key[k]=key[k]=key_current_frame[k]=0;
9683 return true;
9684 }
9685 _key[k]=key[k]=key_current_frame[k]=0;
9686 return false;
9687 }
9688
9689 // Reads the current frame key state directly.
9690 // Scripts can also modify `key_current_frame`.
9691 40183 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9692 {
9693
2/2
✓ Branch 0 taken 36641 times.
✓ Branch 1 taken 3542 times.
40183 if(ignoreDisable) return key_current_frame[k];
9694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
3542 switch(k)
9695 {
9696 case KEY_F7:
9697 case KEY_F8:
9698 case KEY_F9:
9699 return key_current_frame[k];
9700
9701 default:
9702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3542 times.
3542 return key_current_frame[k] && !disabledKeys[k];
9703 }
9704 40183 }
9705
9706 // Only used for a handful of keys, like tilde and Function keys.
9707 // This state is never read within the game.
9708 // It exists so that all keyboard input still functions during replay,
9709 // without inadvertently doing things like toggling throttling if the player
9710 // presses ~
9711 7104 bool zc_get_system_key(int32_t k)
9712 {
9713 7104 return key_system[k];
9714 }
9715
9716 // True for the _first_ frame of a key press.
9717 31878 bool zc_read_system_key(int32_t k)
9718 {
9719 31878 return key_system_press[k];
9720 }
9721
9722 449834 bool is_system_key(int32_t k)
9723 {
9724
2/2
✓ Branch 0 taken 417956 times.
✓ Branch 1 taken 31878 times.
449834 switch (k)
9725 {
9726 case KEY_BACKQUOTE:
9727 case KEY_CLOSEBRACE:
9728 case KEY_END:
9729 case KEY_HOME:
9730 case KEY_OPENBRACE:
9731 case KEY_PGDN:
9732 case KEY_PGUP:
9733 case KEY_TAB:
9734 case KEY_TILDE:
9735 31878 return true;
9736 }
9737 417956 return is_Fkey(k);
9738 449834 }
9739
9740 3542 void update_system_keys()
9741 {
9742
2/2
✓ Branch 0 taken 449834 times.
✓ Branch 1 taken 3542 times.
453376 for (int32_t q = 0; q < 127; ++q)
9743 {
9744
2/2
✓ Branch 0 taken 74382 times.
✓ Branch 1 taken 375452 times.
449834 if (!is_system_key(q))
9745 375452 continue;
9746
9747 74382 key_system[q] = key[q];
9748
1/2
✓ Branch 0 taken 74382 times.
✗ Branch 1 not taken.
74382 key_system_press[q] = key_system[q] && !key_system_previous[q];
9749 74382 key_system_previous[q] = key_system[q];
9750 74382 }
9751 3542 }
9752
9753 3974 void update_keys()
9754 {
9755
2/2
✓ Branch 0 taken 504698 times.
✓ Branch 1 taken 3974 times.
508672 for (int32_t q = 0; q < 127; ++q)
9756 {
9757 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9758
1/2
✓ Branch 0 taken 504698 times.
✗ Branch 1 not taken.
504698 if (!replay_is_replaying())
9759 key_current_frame[q] = key[q];
9760
9761
2/2
✓ Branch 0 taken 503241 times.
✓ Branch 1 taken 1457 times.
504698 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9762 504698 KeyInput[q] = key_current_frame[q];
9763 504698 key_previous_frame[q] = key_current_frame[q];
9764 504698 }
9765 3974 }
9766
9767 bool zc_disablekey(int32_t k, bool val)
9768 {
9769 switch(k)
9770 {
9771 case KEY_F7:
9772 case KEY_F8:
9773 case KEY_F9:
9774 return false;
9775
9776 default:
9777 disabledKeys[k] = val;
9778 return true;
9779 }
9780 }
9781
9782 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9783 {
9784 timer=timer;
9785 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9786 }
9787
9788 // these are here so that copy_dialog won't choke when compiling zelda
9789 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9790 {
9791 return D_O_K;
9792 }
9793
9794 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9795 {
9796 return D_O_K;
9797 }
9798
9799 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9800 {
9801 return D_O_K;
9802 }
9803
9804 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9805 {
9806 return D_O_K;
9807 }
9808
9809 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9810 {
9811 return D_O_K;
9812 }
9813
9814 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9815 {
9816 return D_O_K;
9817 }
9818
9819 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9820 {
9821 return D_O_K;
9822 }
9823
9824 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9825 {
9826 return D_O_K;
9827 }
9828
9829 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9830 {
9831 return D_O_K;
9832 }
9833
9834 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9835 {
9836 return D_O_K;
9837 }
9838
9839 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9840 {
9841 return D_O_K;
9842 }
9843
9844 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9845 {
9846 return D_O_K;
9847 }
9848
9849 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9850 {
9851 return D_O_K;
9852 }
9853
9854 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9855 {
9856 return D_O_K;
9857 }
9858
9859 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9860 {
9861 return D_O_K;
9862 }
9863
9864 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9865 {
9866 return D_O_K;
9867 }
9868
9869 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9870 {
9871 return D_O_K;
9872 }
9873
9874 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9875 {
9876 return D_O_K;
9877 }
9878
9879 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9880 {
9881 return D_O_K;
9882 }
9883
9884 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9885 {
9886 return D_O_K;
9887 }
9888
9889 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9890 {
9891 return D_O_K;
9892 }
9893
9894 /*** end of zc_sys.cc ***/
9895
9896